我正在尝试在我的自定义 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 平板电脑中失败,因为图像消失并且不再出现。
我还没有找到任何解决方案。任何的想法?
谢谢。