How to change the color of a button?

后端 未结 8 1921
臣服心动
臣服心动 2021-02-03 20:08

I\'m new to android programming. How do I change the color of a button?

8条回答
  •  渐次进展
    2021-02-03 20:49

    Through Programming:

    btn.setBackgroundColor(getResources().getColor(R.color.colorOffWhite));
    

    and your colors.xml must contain...

    
    
     #80ffffff
    
    

提交回复
热议问题