How to move/drag an entire android view that contains a bunch of shapes inside? -


i know how drag ball around extending view , overriding ondraw , calculating new coordinates , redrawing ball. if have hundreds of shapes inside view , need entire view moved around shapes together. recalculating every single shape doesn't seem feasible. on iphone can draw bunch of things inside view , move entire view , takes care of drawing things inside view me. have recalculate coordinates of view , set position not inside view. possible on android?

thanks, steven

use canvas.translate() method offset being drawn within ondraw() handler.

track translation offsets based on cursor movement or whatever, , use offsets in call translate().

you can similar effect canvas.scale() handle pinch-zoom.

don't forget save() , restore() put canvas original state!

if want move view around within view, adjust top/left properties , call invalidate(). if complex layout, within relativelayout , use layoutparams position everything.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -