Button bt = (Button)findViewById(R.id.main_imagebtn_mail);
bt.setBackgroundColor(color.white);

解决方案 »

  1.   

    可以做成背景图片,红色button和黑色button 然后点击的时候换图片就行阿
      

  2.   

    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;   
                }
            });
      

  3.   

    不怕烦的话,加个监听,点击时更换背景图片,keyup事件时再换回来
      

  4.   

    这样我使用过了,但是Button的样式被改变了。