Android: textColor of disabled button in selector not showing?

前端 未结 5 1417
梦毁少年i
梦毁少年i 2020-11-30 21:24

I am trying to make a button with a selector my button can have the following states:

  • Enabled/Disabled
  • Pressed/Not Pressed

According to

5条回答
  •  萌比男神i
    2020-11-30 21:45

    The most easy solution is to set color filter to the background image of and button as I saw here

    You can do as follow:

    if ('need to set button disable')
        button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
    else
        button.getBackground().setColorFilter(null);
    

    Hope I helped someone...

提交回复
热议问题