Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText hint doesn't show

My EditText configured as follows won't show the hint:

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:hint="The hint..."
    android:scrollHorizontally="true"
    android:singleLine="true" />

It works if I set android:gravity="left" or if I remove android:scrollHorizontally and android:singleLine attributes, which is not desirable. Any suggestions?

like image 543
venuko Avatar asked Aug 31 '10 10:08

venuko


People also ask

Why use TextInputLayout?

The primary use of a TextInputLayout is to act as a wrapper for EditText(or its descendant) and enable floating hint animations. Rule of Thumb : TextInputLayout should wrap TextInputEditText instead of the normal EditText.

What is TextInput layout?

TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.


4 Answers

using android:ellipsize="end" fixed it for me Weird bug !! (but Android has a lot of these weirdo bug)

like image 92
Someone Somewhere Avatar answered Oct 15 '22 01:10

Someone Somewhere


In Lollipop version the default text and hint text color is white for EditText. So we have to change like this in EditText

android:textColorHint="@color/grey"
like image 29
lal Avatar answered Oct 15 '22 01:10

lal


I wanted my single-line EditText box to scroll but keep the hint on the right also. I had the same issue and got the hint to stick by keeping gravity="right", and setting singleLine="true" and ellipsize="end".

like image 17
Kavi Avatar answered Oct 15 '22 02:10

Kavi


You need to give text color to hint

android:textColorHint="#000000"
like image 7
Ravi Yadav Avatar answered Oct 15 '22 00:10

Ravi Yadav