Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grey out Views. Specifically an EditText?

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!

like image 579
Rogério Peixoto Avatar asked May 23 '11 16:05

Rogério Peixoto


People also ask

How do I turn off text view on Android?

It's possible to preserve both the style of the view and the scrolling behaviour. To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.


1 Answers

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

like image 110
Aleadam Avatar answered Sep 27 '22 18:09

Aleadam