How to set TextColor using setTextColor(ColorsStateList colors)

前端 未结 3 1068
北恋
北恋 2021-01-30 08:56

I need to change text color when state change(pressed, focus)...

How to set the text color of a TextView using ColorsStateList?

3条回答
  •  心在旅途
    2021-01-30 09:25

    You have to use getColorStateList()

    I was also struggling with this problem, if you want to use a state list, you need to declared it in the color resources folder, instead of the drawable folder, and use the setTextColor(getResources().getColorStateList(R.color.your_colors)).

提交回复
热议问题