How to set placeholder in EditText?

2

I created a small Android app containing only one activity. In it I put two EditText components. I want to set placeholders in them, as in HTML5 inputs, but I can not find a solution.

    
asked by anonymous 06.09.2017 / 09:28

2 answers

6

I discovered the solution!

In Android Studio, the EditText does not have the placeholder property, but the android: hint property exists. And with that I also discovered the android: textColorHint property that changes the color 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" />

Result

    
06.09.2017 / 10:11
1

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

    
06.09.2017 / 20:47