对 ListView 进行双指缩放 [英] Pinch-zoom on a ListView

查看:30
本文介绍了对 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.

有人知道做类似事情的例子吗?我尝试遵循此处的代码:自定义视图的捏合缩放,但我最终得到了一个除了捏合手势外不会响应任何触摸事件的 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.

推荐答案

您应该能够按照 捏缩放自定义视图 然后在覆盖 onTouchEvent 时执行类似的操作.这将允许您侦听缩放事件以及列表视图中的所有其他触摸事件.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆