I have recently completed a simple drag and drop shapes game. It had the user drag a shape (ImageView
) to another "empty place holder" ImageView
.
I now want to make this a little more advanced, instead of dragging a simple shape, I want to make a puzzle of various non-orthogonal shapes, for example breaking a circle into 5 different pieces. What I'm having a problem with right now is how to design the layout. I do not know how to make a truly "custom" shaped ImageView
, as far as I can find from my research it's not possible. So my idea for now is to overlap a number of square ImageView
s, each of which will have only a subset of an image and the rest transparent. Thus the final output will look like it's a number of custom shaped ImageView
s.
Example:
+
+
+
Because only the internal sections are "visible" and the rest of the circle is transparent, when all of these pieces are placed in the same spot on the screen, the final image will look like:
I haven't tried this yet... but I foresee at least one problem. When I go to drag the pieces over to this puzzle, they will all "snap" into place when dragged to the same place. Because in reality all I really have here is a picture of a circle inside a ImageView
which has some invisible rectangular boundary around it.
Hopefully this situation is clear. Now my questions:
- Is it possible to have truly custom shaped
ImageView
s instead of my idea of overlapping images? - If what I'm thinking is the best way to handle this puzzle idea, then what property can be changed such that the "drop" action does not happen at the same place for all of these puzzle pieces? If I wanted to "drop" the pizza shaped piece, I'd like it to only snap into place when it go close to the top left of the circle.
Note: I am new to Android programming, and somewhat new to Java/XML as well, it’s very likely I’m overlooking something, so please feel free to suggest other approaches as you see fit.