EditText hint doesn't show

北城以北 提交于 2019-11-27 19:15:00

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

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"

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".

Ravi Yadav

You need to give text color to hint

android:textColorHint="#000000"

No need of android:scrollHorizontally attribute. Remove it.EditText is a fixed item on the screen. we want scroll the layout contains the EditText is enough. that is the best design too. you have put android:ellipsize="end" instead of android:scrollHorizontally.

Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :(

I found no other solution than to:

if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*"))
      editText.setGravity(Gravity.LEFT);
else
      editText.setGravity(Gravity.CENTER);
Hossa The Coder

The below worked for me:

<EditText
    android:id="@+id/UserText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/UserPassword"
    android:layout_marginTop="85dp"
    android:ems="10"
    android:hint="@string/UserHint"
    android:inputType="textPersonName"
    android:singleLine="true"
    android:text="@string/UserName" >

    <requestFocus />
</EditText>
Nandagopal T

This is how, I did for by EditText to have hint in it.

<EditText
    android:id="@+id/productQuantity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right|center_vertical"
    android:hint="@string/quantity"
    android:inputType="numberSigned"
    android:ellipsize="end"
    android:singleLine="true" >
</EditText>

Try changing the hint text color, sometimes the hint color is the same as the background color

android:textColorHint="@color/colorBlack"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!