0
我想在自定义ImageView类AvatarView中做点击效果。带有点击效果的图像
我使用的代码:
// **** Listener onTouch ****.
// Añadimos un listener para su pulsación.
this.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Establecemos un filtrado de color.
AvatarView.this.setColorFilter(0xe0f47521, PorterDuff.Mode.SRC_ATOP);
AvatarView.this.invalidate();
break;
case MotionEvent.ACTION_UP:
// Eliminamos el filtrado de color.
//AvatarView.this.clearColorFilter();
AvatarView.this.setColorFilter(null);
AvatarView.this.invalidate();
break;
}
return false;
}
});
此代码工作完全在我的2.3手机,但它在我的4.1平板电脑由于图像消失,没有再出现失败。
我还没有找到任何解决方案。任何想法?
谢谢。
false表示触摸事件未消耗,因此将传播到底层视图。真正消耗事件,所以儿童不会被通知事件 – AndacAydin 2015-06-04 12:15:11