扩大控件的点击区域

</pre><pre name="code" class="java">private void enlargePwdClickArea(View view) {
        View parent = (View) view.getParent();

        parent.post(new Runnable() {
            public void run() {
                Rect outRect = new Rect();
                view.getHitRect(outRect);
                int tempSize = getResources().getDimensionPixelSize(R.dimen
                        .size_large_click);;
                outRect.left -= tempSize;
                outRect.top -= tempSize;
                outRect.right += tempSize;
                outRect.bottom += tempSize;
                TouchDelegate deldgate = new TouchDelegate(outRect, view);
                if (View.class.isInstance(parent)) {
                    ((View) parent).setTouchDelegate(deldgate);
                }
            }
        });
    }  


你可能感兴趣的:(android,view)