How to grey out a button?

后端 未结 9 728
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 22:23

I have a button defined as shown below. When I want to disable it I use my_btn.setEnabled(false), but I would also like to grey it out. How can I do that?

9条回答
  •  既然无缘
    2020-12-22 23:03

    You have to provide 3 or 4 states in your btn_defaut.xml as a selector.

    1. Pressed state
    2. Default state
    3. Focus state
    4. Enabled state (Disable state with false indication; see comments)

    You will provide effect and background for the states accordingly.

    Here is a detailed discussion: Standard Android Button with a different color

提交回复
热议问题