How to set placeholder in Edittext?

Asked

Viewed 4,139 times

3

I created a small app for Android containing only one Activity. In it I put two components Edittext. I wish to define placeholders in them, as in HTML5 inputs, but find no solution.

  • android:hint="What you want to put"

2 answers

10


I figured out the solution!

In Android Studio, the component Edittext does not own the property placeholder, but there is the property android hint:. And with that I also discovered the property android:textColorHint changing the colour of the text in question.

See below for my example.

<EditText
        android:id="@+id/edtAltura"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="15sp"
        android:hint="Ex.: 1.82"
        android:textColorHint="#bbb"
        android:inputType="numberDecimal" />

Upshot

Propriedade android:hint

3

Go to the Edittext properties and search for Hint. It works as a placeholder.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.