简体   繁体   English

Android 中的可滚动/可缩放视图

[英]Scrollable/zoomable view in Android

In iOS, since 2.0 in 2008, there's the UIScrollView class to provide a view that the user can pinch zoom and drag around.在 iOS 中,从 2008 年的 2.0 开始,有 UIScrollView 类来提供用户可以捏缩放和拖动的视图。

Is there an equivalent class in Android Jellybean and up? Android Jellybean 及更高版本中是否有等效的类?

I've found some questions here, where the answer is to make a custom class containing all the programming needed to detect the pinching and dragging, and then adjust an ImageView accordingly.我在这里发现了一些问题,答案是制作一个自定义类,其中包含检测捏合和拖动所需的所有编程,然后相应地调整 ImageView。

Is this really the way to go for such a basic touch screen function?这真的是实现这种基本触摸屏功能的方法吗?

I suggest you to try the one of the following libraries, depending on what kind of content you need to handle:我建议您尝试以下库之一,具体取决于您需要处理的内容类型:

1. Generic Zoomable View : https://github.com/Polidea/android-zoom-view 1. 通用可缩放视图https : //github.com/Polidea/android-zoom-view

Just wrap you content with an instance of ZoomView:只需使用 ZoomView 实例包装您的内容:

//...
ZoomView zoomView zoomView = new ZoomView(getActivity());
zoomView.addView(contentInflatedView);
//add zoomView to your layout...

2. Zoomable ImageView: https://github.com/chrisbanes/PhotoView 2. 可缩放 ImageView: https : //github.com/chrisbanes/PhotoView

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

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