How to grey out Views. Specifically an EditText?

2019-07-13 15:41发布

Hey guy's First of all thanks for reading this. I'm having trouble to find a way to change my EditText when I loose focus to it. I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.

Anyone?

Greetings!

1条回答
贼婆χ
2楼-- · 2019-07-13 16:19

You can set different colors to the text based on an OnFocusChangeListener

Another option is to set a style in xml. See this question for details: Android: change style when focused

To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation

查看更多
登录 后发表回答