Android button background color

后端 未结 10 1928
轮回少年
轮回少年 2020-12-08 00:25

I am trying to set the background color of a button in my app and I am unable to achieve the result that I want...

The color that I am trying to set is holo_gr

10条回答
  •  执笔经年
    2020-12-08 00:49

    In order to keep the style, use:

    int color = Color.parseColor("#99cc00");
    button.getBackground().mutate().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC));
    

提交回复
热议问题