How to change the color of a button?

后端 未结 8 1824
臣服心动
臣服心动 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:44

    To change the color of button programmatically

    Here it is :

    Button b1;
    //colorAccent is the resource made in the color.xml file , you can change it.
    b1.setBackgroundResource(R.color.colorAccent);  
    

提交回复
热议问题