Reputation: 3203
I'm trying to smoothly move a view around inside its parent based on touch. I have the OnTouchListener working and tracking movements. How do I actually move the view? I've tried using RelativeLayout.LayoutParameters and setting the margins, but the margins only accept int values, which makes the view jittery. I've tried using a TranslateAnimation which will let me use a float, but that only moves the canvas, so my touch events are left behind. Has anybody figured out a way to smoothly do this?
Upvotes: 2
Views: 2363
Reputation: 4535
Best solution is rewriting a custom ViewGroup subclass, which will torture your soul. If succeeded, be sure that you have superhumanly nerves :).
Second solution is easier one but works if and only if your view consist of a image. Thus you can write a custom View subclass and refine image on onDraw() method's Canvas.
My last solution would be OpenGL.
Also, i am not sure but maybe on relative layout kinda layout updating margin and then invalidate() view might work.
Good Luck!
Upvotes: 2