5

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!

Rogério Peixoto
  • 2,176
  • 2
  • 23
  • 31

1 Answers1

6

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

Community
  • 1
  • 1
Aleadam
  • 40,203
  • 9
  • 86
  • 108
  • For next time, that should really be another question. See the updated answer for setting the opacity. – Aleadam May 23 '11 at 19:11
  • the problem is that I don't have access to setAlpha through my editText.. how can I access a method from the superclass (view) through the subclass (edittext)?? sorry for those newbie questions it's my first android project! – Rogério Peixoto May 25 '11 at 13:21
  • All derived classes have access to the public methods of the superclass. I would suggest you to read this before continuing: http://download.oracle.com/javase/tutorial/java/IandI/subclasses.html – Aleadam May 26 '11 at 03:26
  • Looking back to this after a few years it's nostalgic hahahaha I've come a long way – Rogério Peixoto Jun 13 '16 at 04:49
  • 1
    for setAlpha – k4dima Oct 26 '19 at 14:26
  • “setAlpha” did the job. Thanks! – Sam Chen Nov 08 '19 at 20:20