lehtu
lehtu

Reputation: 907

How to get pinch zoom to work on RelativeLayout? - Android

In my case I have RelativeLayout which contains many EditText boxes and lines between them. What I need now is to get Zoom work on this. I have googled a lot(in days) and I haven't found the answer how to do this.

Firstly it would be easiest to all of us if I start with few questions, so:

  1. Is that true 'Pinch zoom' is only supported on ImageView, MapView and WebView?
  2. Is it even possible to get any kinda zoom work on RelativeLayout? (I know one and imo last choice is to use buttons and multiple all size values and/or refactor whole "view" every time button is touched)
  3. If it is possible to make work in anyway easier than above I would love to hear how it should be done.

Edit: And I tried to use Animation and there was some kind of scale which worked pretty well, but the only and fatal problem was that EditTextBoxe's Touching bounds didn't scale.. Or even move, so they were on original position and size. Is there any suggestions to this one?

Upvotes: 0

Views: 3291

Answers (2)

Femi
Femi

Reputation: 64700

You should look at http://code.google.com/p/android-pinch/source/browse/#svn%2Ftrunk%2Fsrc%2Fcom%2Fnikkoaiello%2Fmobile%2Fandroid%253Fstate%253Dclosed for a couple of implementations if you haven't already: I get the sense that you are right and those 3 are the only Views for which there is any native support for the pinch zoom metaphor.

As far as the bounds not scaling without more knowledge about the animations you are using that appears to be a common problem: does overriding the animation and setting http://developer.android.com/reference/android/view/animation/Animation.html#willChangeBounds%28%29 to return true help in any way?

Upvotes: 0

hackbod
hackbod

Reputation: 91351

RelativelyLayout doesn't even zoom at all. Or scroll. You are looking in the wrong place. You would need to put your view hierarchy in a container that does this. If it is going to zoom, it will be tricky because the container will need to apply a scale factor to both the drawing and touch events going through it.

Upvotes: 1

Related Questions