0

I’m trying to create an app that allows you to store information regarding handball matches, it’s a project school, things like number of savings, where the goalkeeper gets the most goals etc, the problem tho is that I’d need a sort of “handball field”. although I’d just one area and not the full field, something like this → field image

How should I do this? Can i simply just draw it in XML using shapes etc? Thank you all in advance

Fil
  • 11
  • 1
  • Is it just a static background image? You might want to look into vector drawables: https://developer.android.com/guide/topics/graphics/vector-drawable-resources - you can import an SVG from a vector drawing program like Inkscape or Illustrator. Then you could just stick it in an ``ImageView``, and arrange your other views on top of it (like text labels etc) - a ``ConstraintLayout`` is probably your best bet, because you can do things like constrain the aspect ratio (so the image scales up right) and anchor the other views relative to the sides of your image – cactustictacs Jan 21 '22 at 20:11
  • It has to be a image view button, si the analyst can select from which area and which lenght the shot came from. My question is can I really just draw a hand ball field with vectors drawables? – Fil Jan 23 '22 at 10:05
  • I drew my svg in inkscape however i cant import it in Android Studio as it shows a blank preview... – Fil Jan 23 '22 at 14:34
  • A ``Button`` is just a view that detects a click, you probably want a custom view if you need to detect where the tap occurred. (You could also just overlay invisible Views/Buttons to create tappable areas, in which case the image would still just be a background). And you can import SVGs from Inkscape, but some features aren't supported (usually the importer will warn you): https://developer.android.com/studio/write/vector-asset-studio#svg-support In my experience they might need some tweaking in the XML editor (like fill colour), and Inkscape has different export options too, I'd experiment! – cactustictacs Jan 23 '22 at 20:40

1 Answers1

0

The easiest way to achieve it is getting a image of field and using it as a ImageView BUT, depending on what you wanna do, It may not work (For example, aligning other views over the field image).

If you wanna do this "native" (read as drawing in xml), you'll need to understand the idea of using a drawable as background (a border) and create a new view for every line of field. This is a more complext alternative.

If you have no idea of using a drawable as background, check this question (although i recommend using first and easiest alternative): How do I put a border around an Android textview?

Filipe Oliveira
  • 850
  • 7
  • 13
  • Thank you for your response , I will need this hand ball field to store data regarding the goalkeeper, for example from where he gets the most goal, which direction and which lenght, depending where the user touches the area – Fil Jan 21 '22 at 17:18