Reputation: 33
I´m new in android development. I want to create a game where the user needs to quickly drag and drop balls with the finger in the screen to specific locations in order to win. I don´t know if i can do this with simple ImageViews or i need to use canvas or other thing to draw in the screen. I have tried to drag and drop an ImageView on top of another ImageView but it does not seem to work very well and i'm hesitating if i need to do it drawing figures instead of using the ImageViews or to do something else. Please advice. Any help is apreciated. Thank you.
Upvotes: 0
Views: 480
Reputation: 4775
ImageViews are Views designed to hold image drawables, which isn't really needed in your case - you can use a simple View with a color background or implemended onDraw
method, you can use an ImageView just as well.
Asfor the drag and drop, what you need is any View with implemented onTouch
method so that the view changes its position on screen with ACTION_MOVE touch events.
If you're interested, i have implemented a simple frame layout with drag and drop functionality. My layout requires long-click to start drag, but it can be easily modified so it won't. Check it out at my github page. You can clone the project and run demo activity to see how it works, and start from there.
Upvotes: 2