I want to make a multi line edit text but the problem is that whenever i enter new line height of edit text increases. how to fix its height. My code is
<EditText
android:id="@+id/editAdditionalInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editPhoneCutomerDetails"
android:layout_alignParentBottom="true"
android:layout_marginBottom="60dp"
android:layout_below="@+id/editPhoneCutomerDetails"
android:layout_marginTop="10dp"
android:background="@drawable/message_additional_box1x"
android:ems="10"
android:padding="10dp"
android:gravity="top">
<requestFocus />
</EditText>
To fix the size of editText you can use
android:singleLine="true"
but it can limit your editText line to 1 .
if you want more lines in editText then use the following property.
Use android:lines="3"
.
Use android:lines="2"
for fixing multilines and for fixing single line use android:singleLine="true"
for example use like this as shown for multilines
<EditText
android:id="@+id/.."
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:maxLength="20"
android:lines="2"// fix the multiline limit
android:textColor="#000000" />
for example use like this as shown for single line
<EditText
android:id="@+id/.."
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:maxLength="20"
android:singleLine="true"// fix the single line limit
android:textColor="#000000" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With