I just have a quick question about how you would typically approach this. I am not sure if you have seen the game Paper Toss or anything similar where you place your finger over an existing image drag it for bit (lets say by pulling the imageview) and let go which makes this image move across the screen.
To do something like that, what would be the best way to handle such graphics (mainly concerned about graphics motion and touch event):
-Have an imageview and OnTouchListener that will get the x/y and do a translateAnimation to every X/Y and then do translateAnimation of the image across the screen when the touch is lifted
-OR have surface view and draw an bitmap of the image on Canvas and have the OnDraw method getting the X/Y coordinates of the touch event and draw bitmaps accordingly
I am always confused which one to go with and why? (I am aiming for Android 2.3 so drag/drop is something out of scope for this)
PS: I assume that Canvas and surfaceview comes always together so correct me if I am wrong
PS: I assume that Canvas and surfaceview comes always together so correct me if I am wrong
Yes you are correct they both come together.
First in animation(Either Translate,Rotate,Scale) we just change the position, view of ImageView for a specific time(meanwhile it show effect of animation). then it will come in its original position.
But in canvas, We change the ImageView( we draw Bitmap here not image view)permanently on base of it coordinate. Suppose you want to change you Image where ever your finger touch then simple draw it with new coordinate that you got from
OnTouchEvent()Finally i will say that nothing is best it based on our requirement. Surface and canvas used mainly in Gaming context.