在一个ListView捏缩放 [英] Pinch-zoom on a ListView
问题描述
我有一个ListView,其中包含了一些的TextView的安排使用自定义的适配器。
I have a ListView which contains a few TextView's arranged using a custom adapter.
我想这样做,就是实现双指缩放这个ListView中,这样当用户捏,就可以增加或减少文字的大小。
What I would like to do, is implement pinch-to-zoom on this ListView, so that when the user pinches, they can increase or decrease the size of the text.
有谁知道在做一些类似的例子?我试着按照code在这里:双指缩放自定义视图,但我结束了一个ListView任何触摸事件,除了捏姿态,不会回应。
Does anyone know of examples of doing something similar to this? I tried following the code here: Pinch zoom for custom view, but I ended up with a ListView that would not respond to any touch events except the pinch gesture.
我希望这是可能的,而无需编写一个扩展的ListView一个新的类。
I'm hoping this is possible without writing a new class that extends ListView.
推荐答案
您应该能够跟随的捏缩放自定义视图然后做这样的事情。这将允许你听一个大型活动,以及在列表视图的所有其他触摸事件。
You should be able to follow the Pinch zoom for custom view and then do something like this when overriding the onTouchEvent. This will allow you to listen for a scale event, as well as all other touch events in the listview.
@Override
public boolean onTouchEvent(MotionEvent ev) {
// Let the ScaleGestureDetector inspect all events.
mScaleDetector.onTouchEvent(ev);
return super.onTouchEvent(ev);
}
这篇关于在一个ListView捏缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!