4

I'm looking to build a simple input form for username/password, and I was wondering if it was possible to mimic the functionality that many websites offer, namely a temporary string within a text input displaying what the field's purpose is. Essentially, I need something like this:

enter image description here

When the user hasn't yet focused in on the text input, it should display "USERNAME" in a different format. When the user has focused in on the text field, the field is cleared and focus is set and the style is changed. Is there a way to do this easily?

Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411

2 Answers2

5

look at the properties of the edittext - there is a "hint" property that does just that.

android:hint="Enter Username"

jkhouw1
  • 7,320
  • 3
  • 32
  • 24
2

You can simply set android:hint="USERNAME" in a particular edittext.

When you will write something in that edittext, it will clear the hint and set your text.Simple...

Deep Mehta
  • 1,237
  • 2
  • 11
  • 17