Android 扩大触摸的触发区域 TouchDelegate

Android SDK提供了专门用于扩大触摸区域的类TouchDelegate


具体用法(delegate--需要被扩大触摸区域的view):
final View parent = (View) delegate.getParent();
parent.post( new Runnable() {
    // Post in the parent's message queue to make sure the parent
    // lays out its children before we call getHitRect()
    public void run() {
        final Rect r = new Rect();
        delegate.getHitRect(r);
        r.top -= 4;
        r.bottom += 4;
        parent.setTouchDelegate( new TouchDelegate( r , delegate));
    }
});
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
  

你可能感兴趣的:(Android学习笔记)