在scrollView android上实现缩放

发布于 2024-12-08 19:30:38 字数 448 浏览 5 评论 0原文

我正在尝试创建一个在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

还不是爱你 2024-12-15 19:30:38

根据您的具体要求,这里有几种可能的方法来解决此问题:

  • 您可以创建一个视图并在 onScroll 事件期间调整其布局参数。
  • 对于普通缩放,您可能需要查看动画。这应该可以有效地为您提供缩放效果。对于滚动视图中的特定元素。
  • 如果需要缩放整个scrollView,可以用视图容器(例如LinearLayout)包围它,并在此视图上执行缩放。

Depending on your specific requirements here are a couple possible approaches to this problem:

  • You can create a view and adjust its layout parameters during the onScroll event.
  • For plain zooming you might want to look at the animation. This should effectively give you a zoom effect. For a specific element in the scroll view.
  • If you need to zoom the whole scrollView, you can surround it with a view container (eg LinearLayout) and perform the zoom on this view.
美胚控场 2024-12-15 19:30:38

我不确定你使用 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.

萤火眠眠 2024-12-15 19:30:38

如果您的目的是为图像提供缩放功能,那么您很幸运!我编写了一个相当全面的类,它扩展了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文