Snake
Snake

Reputation: 14648

Panning a layout with imageviews on it

I have been puzzled by how to approach this for a while. I have Framelayout with over 20 image views on it. I want to be able to pan the framelayout. Basically, touching and dragging causes the background image to pan (and the 20 image views to move along).

This is similar to what strategy games do (you have map and buildings).

I read all about panning and zooming and they all talking about doing this for single imageview. In my case, not only it is a layout but also it has other views.

How do I approach this? Any pointers ? Thanks

Upvotes: 1

Views: 47

Answers (2)

Xjasz
Xjasz

Reputation: 1248

I have a github project for zooming and panning although its for View Groups it would be easy to change for a View. Check it out let me know if you have a question it is unfinished but works.

https://github.com/Xjasz/AndroidZoomableViewGroup

Copy the class and extends FrameLayout instead of ListView. Then make sure in your XML to use the class instead of a FrameLayout.

Upvotes: 1

Andrew Orobator
Andrew Orobator

Reputation: 8646

You could have a TouchInterceptor/Custom view where on touch, you offset the view from its parent by the delta of the current touch coords from the last touch coords.

Upvotes: 0

Related Questions