重写ViewGroup的dispatchTouchEvent(MotionEvent event)函数 我曾经做过的一个获得checkbox的区域的代码:// Padding to increase clickable areas on left & right of each list item private final static float SELECT_PAD = 10.0F; float paddingScale = getContext().getResources().getDisplayMetrics().density; int selectPadding = (int) ((SELECT_PAD * paddingScale) + 0.5); mSelectRight = findViewById(R.id.selected).getRight() + selectPadding;
我曾经做过的一个获得checkbox的区域的代码:// Padding to increase clickable areas on left & right of each list item
private final static float SELECT_PAD = 10.0F;
float paddingScale = getContext().getResources().getDisplayMetrics().density;
int selectPadding = (int) ((SELECT_PAD * paddingScale) + 0.5);
mSelectRight = findViewById(R.id.selected).getRight() + selectPadding;
然后通过event.getAction()来获得动作,在你的情况下是点击图片事件.最后做处理.