关于Button的问题 Button bt = (Button)findViewById(R.id.main_imagebtn_mail);bt.setBackgroundColor(color.white); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以做成背景图片,红色button和黑色button 然后点击的时候换图片就行阿 1.使用selector写一个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; } }); 不怕烦的话,加个监听,点击时更换背景图片,keyup事件时再换回来 这样我使用过了,但是Button的样式被改变了。 如何实时监听内核kmsg信息,并将其写入文件存在sdcard上??? Android新人求助,赋值错位乱序问题 在android,我怎么判断一个应用程序是否联网,以及怎么判断他是否断开连接,急需啊。。 Android如何访问电脑上的服务器 怎么把标签放在屏幕底部 按钮无法显示。。请教。。 如何将mp4格式的视频和指定的播放器进行绑定 安卓线程问题 安卓app调用系统照相功能拍出的图片在相册里面看不到,但在文件中看得到 (小白求教)android 开发中对于几个文件的困扰 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;
}
});