在scrollView android上实现缩放
我正在尝试创建一个在Android 中使用scrollView 的应用程序。恰好scrollView不支持矩阵。因此我不能做这样的事情:
Matrix matrix = new Matrix();
Matrix eventMatrix = new Matrix();
// possible touch states
final static int NONE = 0;
final static int DRAG = 1;
final static int ZOOM = 2;
int touchState = NONE;
有人知道是否可以通过其他过程实现缩放和捏合功能吗?感谢您的帮助。
谢谢。
[重新编辑]
scrollView 将用作容器,以便可以将各种 UI 放置在其中。这样,scrollView 就可以作为一个 UI 部分。
谢谢。
I am trying to create an application that employs the scrollView in Android. It so happens that scrollView does not support matrices. Therefore I can not do something like this:
Matrix matrix = new Matrix();
Matrix eventMatrix = new Matrix();
// possible touch states
final static int NONE = 0;
final static int DRAG = 1;
final static int ZOOM = 2;
int touchState = NONE;
Would anyone know if it is possible to attain the zooming as well as pinching functionality through other process? Appreciate the help.
Thanks.
[RE-EDIT]
The scrollView will serve as a container so that various UIs can be placed inside it. That way the scrollView can serve as one UI part.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您的具体要求,这里有几种可能的方法来解决此问题:
Depending on your specific requirements here are a couple possible approaches to this problem:
我不确定你使用 ScrollView 的目的是什么,但你应该看看这篇 Android 开发者文章 - 了解多点触控以获得捏合/缩放功能。
I'm not sure what you are using the ScrollView for but you should take a look at this android developer article - Making sense of multitouch to get pinch/zoom functionality.
如果您的目的是为图像提供缩放功能,那么您很幸运!我编写了一个相当全面的类,它扩展了 ImageView 以添加捏缩放和平移功能,并进行了边界测试。请查看此处。如果这不是您想要的,那么您必须提供更多关于您想要做什么的信息。但是,此代码可能适合您的需求。
If your intention is to provide zoom capabilities to an image, then you're in luck! I wrote a fairly thorough class that extends ImageView to add pinch zoom and panning functionality, with boundary testing. Check it out here. If that's not what you want, then you'll have to provide more information about exactly what you want to do. But, this code might be adaptable to your needs.