Button bt = (Button)findViewById(R.id.main_imagebtn_mail);
bt.setBackgroundColor(color.white);
bt.setBackgroundColor(color.white);
解决方案 »
- 使用Gson解析json报错了,哪位英雄看下。。
- android 用socket获取大量数据时,不全,时间太久
- U8800这货的屏幕分辨率是多少?
- android视频播放在其他设备上(液晶显示器,电视机)全屏问题?
- android开发天气预报无法通过GPRS访问webservice
- Android平台应用流量统计开发求助
- 怎么播放flv文件——顶贴给分
- java.net.InetAddress.getByName 程序直接退出 ??
- 求助各位大神:Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
- Android MediaPlayer为什么监听不到视频播放结束
- eclipse自动联想功能导致假死
- 各位,已经好久没解决了,关于Activity传递bundle的问题。谢谢了
写一个xml文件,设置selector的各个item属性值,具体用法楼主可以搜索一下2.按下按钮时进行颜色过滤
参考代码 /**
* 按下这个按钮进行的颜色过滤
*/
public final static float[] BT_SELECTED = new float[] {
2, 0, 0, 0, 2,
0, 2, 0, 0, 2,
0, 0, 2, 0, 2,
0, 0, 0, 1, 0 };
/**
* 按钮恢复原状的颜色过滤
*/
public final static 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 };
...
mPlay.setOnTouchListener(new ImageButton.OnTouchListener() {
//按下时进行图片颜色的过滤处理
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.getBackground().setColorFilter(
new ColorMatrixColorFilter(BT_SELECTED));
v.setBackgroundDrawable(v.getBackground());
} else if (event.getAction() == MotionEvent.ACTION_UP) {
v.getBackground().setColorFilter(
new ColorMatrixColorFilter(BT_NOT_SELECTED));
v.setBackgroundDrawable(v.getBackground());
}
return false;
}
});