Set temporary text in EditText / TextView in Android?

I want to create a simple input form for a username / password, and I was wondering if it is possible to simulate the functionality that many websites offer, namely a temporary line in text input showing what the purpose of the field is. Essentially, I need something like this:

enter image description here

When the user has not yet focused on typing, he should display "USERNAME" in a different format. When the user focuses on the text field, the field is cleared, the focus is set and the style changes. Is there any way to make this easy?

+4
source share
2 answers

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

android: hint = "Enter Username"

+5
source

You can simply set android: hint = "USERNAME" in a specific editor.

When you write something in this edittext, it will clear the tooltip and set your text. Plain...

+2
source

All Articles