简体   繁体   English

如何缩小缩放以在RelativeLayout上工作? -安卓

[英]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. 就我而言,我有RelativeLayout ,其中包含许多EditText框和它们之间的线。 What I need now is to get Zoom work on this. 我现在需要的是让Zoom工作。 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 ? 仅在ImageView, MapView and WebView上支持真正的“捏缩放”功能吗?
  2. Is it even possible to get any kinda zoom work on RelativeLayout? 甚至有可能在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) (我知道,imo的最后选择是使用按钮和多个所有大小值和/或每次触摸按钮时重构整个“视图”)
  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. 编辑:我尝试使用动画,并且存在某种比例的效果很好,但是唯一致命的问题是EditTextBoxe的Touching边界无法缩放。甚至无法移动,因此它们处于原始位置和大小。 Is there any suggestions to this one? 对这个有什么建议吗?

RelativelyLayout doesn't even zoom at all. RelativelyLayout甚至根本不缩放。 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. 如果要缩放,这将非常棘手,因为容器将需要对通过它的绘图和触摸事件都应用比例因子。

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. 您应该查看http://code.google.com/p/android-pinch/source/browse/#svn%2Ftrunk%2Fsrc%2Fcom%2Fnikkoaiello%2Fmobile%2Fandroid%253Fstate%253D关闭 (如果有的话)还不是:我觉得您是对的,这3个视图是对捏缩放比喻有任何本机支持的唯一视图。

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? 至于在没有更多关于您正在使用的动画的知识的情况下无法缩放范围的问题,这似乎是一个常见问题:是否覆盖了动画并设置了http://developer.android.com/reference/android/view/animation/Animation。 html#willChangeBounds%28%29以任何方式返回真正的帮助?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM