EditText hint not showing in 5.0.1

2019-06-26 02:58发布

问题:

I have the latest 5.0.1 update and the EditText hint has stopped showing:

I have:

<EditText
     android:id="@+id/editTextLocation"
     android:layout_width="wrap_content"
     android:layout_marginEnd="5dp"
     android:layout_marginLeft="5dp"
     android:layout_marginRight="5dp"
     android:layout_marginStart="5dp"
     android:layout_weight="80"
     android:clickable="false"
     android:focusable="false"
     android:focusableInTouchMode="false"
     android:hint="@string/chooseLocationHint"
     android:longClickable="false"
     android:textColor="#000000"
     android:textSize="15sp"
     android:background="@color/white"
     android:lines="1"
/>

I've looked through a few "solutions" but they're all quite old and unrelated to 5.0.1

Thanks

回答1:

You need to give the hint a colour:

android:textColorHint="#000000"


回答2:

Oddly enough the hint won't display when the EditText doesn't have focus unless the ellipse size is defined (e.g. ellipsize="end")