Reputation: 328
EditText is not showing hint on changing the height of the EditText
This is my code
<EditText
android:id="@+id/editText"
android:layout_width="200dp"
android:layout_height="20dp"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="69dp"
android:drawableLeft="@drawable/ic_action_user"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:textSize="16dp"/>
Upvotes: 0
Views: 221
Reputation: 142
As @Sky Alligator mentioned correctly but still then you want to maintain height=20dp, go for this one. Either set
android:background="@null"
Or
android:background="@drawable/bg_rect_edittext"
bg_rect_edittext.xml
<item xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<corners android:radius="3dp" />
<solid android:color="#FFFFFF" />
</shape>
</item>
Hopefully this may help you!
Upvotes: 0
Reputation: 13617
Yes its because of your layout_height
your layout_height
should be at least 36dp
to show your text.
Also your should use sp
for text size not dp
<EditText
android:id="@+id/editText"
android:layout_width="200dp"
android:layout_height="36dp" // 36 dp or more or wrap_content
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="69dp"
android:drawableLeft="@drawable/ic_action_user"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:textSize="16sp"/>
Upvotes: 1
Reputation: 6426
you are giving too less height
as compared to your textSize
. if you really want to go with this size then you need to give padding in "-"
(minus)
<EditText
android:id="@+id/editText"
android:layout_width="200dp"
android:layout_height="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="69dp"
android:padding="-5dp"
android:drawableLeft="@drawable/ic_action_user"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:textSize="16sp"/>
Upvotes: 1