How to add button tint programmatically

前端 未结 15 938
时光取名叫无心
时光取名叫无心 2020-11-30 23:38

In the new AppCompat library, we can tint the button this way:

15条回答
  •  情歌与酒
    2020-12-01 00:22

    Have you tried something like this?

    button.setBackgroundTintList(getResources().getColorStateList(R.id.blue_100));
    

    note that getResources() will only work in an activity. But it can be called on every context too.

提交回复
热议问题