import android.content.Context;
import android.graphics.ColorMatrixColorFilter;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
public class MyImageView extends ImageView{
public MyImageView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
this.setOnTouchListener(VIEW_TOUCH_DARK);
}
public static final OnTouchListener VIEW_TOUCH_DARK = new OnTouchListener() {
//变暗(三个-50,值越大则效果越深)
public final float[] BT_SELECTED_DARK = new float[] { 1, 0, 0, 0, -50, 0, 1,
0, 0, -50, 0, 0, 1, 0, -50, 0, 0, 0, 1, 0 };
/*
//变亮
public final float[] BT_SELECTED_LIGHT = new float[] { 1, 0, 0, 0, 50, 0, 1,
0, 0, 50, 0, 0, 1, 0, 50, 0, 0, 0, 1, 0 };
//恢复
public final float[] BT_NOT_SELECTED = new float[] { 1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 };
*/
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
ImageView iv = (ImageView) v;
iv.setColorFilter(new ColorMatrixColorFilter(BT_SELECTED_DARK));
} else if (event.getAction() == MotionEvent.ACTION_UP) {
ImageView iv = (ImageView) v;
iv.clearColorFilter();
}
return false; //如为false,执行ACTION_DOWN后不再往下执行
}
};
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有