Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix the size of multiline edit text

Tags:

android

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>
like image 747
Avinash Kumar Pankaj Avatar asked Jan 01 '13 12:01

Avinash Kumar Pankaj


2 Answers

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

like image 125
Chirag Avatar answered Oct 22 '22 19:10

Chirag


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" />
like image 40
Rahul Baradia Avatar answered Oct 22 '22 20:10

Rahul Baradia