Click on the small button to expand the scope of the event

We often encounter in the usual combat development process some of this demand, we have to click a small button to jump to another screen pop up or after clicking a DialogFragment, we found that because the button is too small is not easy clicks, such very bad experience, how do?

Renderings

Many long people would certainly say to View add Padding on the line Well, yes, this would solve the problem, but have you ever wondered if the View has a background image, the results you added a Padding, View background image deformation, and this under the scope of the case to increase clicks by adding Padding scheme will not work, how to crack? In fact, very simple A little brains to put this issue is resolved, we give the little button or peripheral wrapped in a LinearLayout RelativeLayout, when we click on the periphery of LinearLayout or RelativeLayout when this event to pass small button immediately to solve the problem

Key Code:

public class FatArrowView extends RelativeLayout {
//拦截事件
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {( http://www.my516.com)
Log.v(TAG,"onInterceptTouchEvent start...");
return true;
}

// The event distributed to our children CheckBox View
@Override
public boolean onTouchEvent (MotionEvent Event) {
Log.v (TAG, "onTouchEvent Start ...");
// When the finger leaves the screen to set the CheckBox state
if ( event.getAction () == MotionEvent.ACTION_UP) {
ischeck = ischeck;!
mCheckBox.setChecked (ischeck);
}
return to true;
}
}

Guess you like

Origin www.cnblogs.com/hyhy904/p/11369924.html