Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android EditText hint does not appear

It seems to be the most weird thing that I've ever come across.

Here is a layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<EditText        
    android:id="@+id/GuessAppEditText"
    android:lines="1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="center_horizontal"        
    android:inputType="textCapWords"
    android:hint="@string/Hint" />

</RelativeLayout>

The hint of EditText is not shown.

If I remove either android:gravity="center_horizontal" or android:inputType="textCapWords", hint becomes visible.

I have absolutely no idea what has gravity and textCapWords to do with hint. Is it another Android bug or am I doing something wrong? In the former case, what would be a workaround? I want my text to be center-aligned and capitalized and hint to be shown. Or I want too much from poor Android?

like image 770
Nick Avatar asked Oct 26 '12 17:10

Nick


1 Answers

it's 2021 and this still seems to be an issue, so for anyone running trying to use an EditText and not seeing the hint in the designer you can add tools:background="@android:color/transparent" or assign any color to the background and the hint will appear.

like image 141
szaske Avatar answered Sep 19 '22 14:09

szaske