TouchDelegate
来源:互联网 发布:linux服务器系统命令 编辑:程序博客网 时间:2024/05/29 03:17
/** * Helper class to handle situations where you want a view to have a larger touch area than its * actual view bounds. The view whose touch area is changed is called the delegate view. This * class should be used by an ancestor of the delegate. To use a TouchDelegate, first create an * instance that specifies the bounds that should be mapped to the delegate and the delegate * view itself. * <p> * The ancestor should then forward all of its touch events received in its * {@link android.view.View#onTouchEvent(MotionEvent)} to {@link #onTouchEvent(MotionEvent)}. * </p> *
简单点说,就是一般我们只能Click这个View2的时候,View2才响应,但是我们想要Click这个View1的Bounds内,这个View2也要响应。
就是这么简单。。。
所以我们使用时候有:(注:bounds以view1为坐标)
- TouchDelegate td = new TouchDelegate(bounds, view2);
- view1.setTouchDelegate(td);
eg:点击iv1,iv2产生效果
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/iv1" android:layout_width="120dp" android:layout_height="100dp" android:layout_marginLeft="100dp" android:background="@drawable/list_item_bg" > </ImageView> <ImageView android:id="@+id/iv2" android:layout_width="120dp" android:layout_height="100dp" android:layout_below="@id/iv1" android:background="@drawable/night_list_item_bg" > </ImageView></RelativeLayout>
java:
Rect rect = new Rect(0, 0, iv1.getWidth(), iv1 .getHeight()); System.out.println(rect.toString()); iv1.setTouchDelegate(new TouchDelegate(rect, iv2));
- TouchDelegate
- Android TouchDelegate
- TouchDelegate分析
- Android TouchDelegate
- TouchDelegate的用法
- clipChild、clipToPadding和TouchDelegate
- android之view的TouchDelegate
- 关于Android TouchDelegate源码解析
- 关于Android TouchDelegate源码解析
- Android TouchDelegate 扩大点击区域
- 利用TouchDelegate提升用户体验
- 利用TouchDelegate提升用户体验
- 利用TouchDelegate提升用户体验
- Android 开发 Tip 9 -- TouchDelegate
- Android中TouchDelegate的用法浅析
- TouchDelegate 来增大按钮的点击区域
- Android 扩大触摸的触发区域 TouchDelegate
- 使用TouchDelegate扩大View的点击区域
- SQL Server 2008 转换为 SQL 2005 数据库 脚本生成
- [MFC] Edit Control 编辑框
- 利用PDFLib生成PDF文档
- hdu 4607 求树的直径
- The 21th-30th things after installing Ubuntu 12.04
- TouchDelegate
- 关于串行通信取代并行通信的解释
- 面向对象之继承
- Linux下的函数执行时间的统计方法
- WinCE在工业生产现场采集数据的应用
- 不用防火墙自动对付CC攻击防范vbs
- MYSQL SHOW VARIABLES简介
- 2011年新篇90后"所谓黑客"名单
- 如何合并两个vector?