Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Vertical alignment for multi line EditText (Text area)

Use android:gravity="top"


This is similar to CommonsWare answer but with a minor tweak: android:gravity="top|start". Complete code example:

<EditText
    android:id="@+id/EditText02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lines="5"
    android:gravity="top|start"
    android:inputType="textMultiLine"
    android:scrollHorizontally="false" 
/>

U can use this Edittext....This will help you.

<EditText
android:id="@+id/EditText02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="5"
android:gravity="top|left"
android:inputType="textMultiLine" />

Use this:

android:gravity="top"

or

android:gravity="top|left"

<EditText android:id="@+id/EditText02" android:layout_width="120dp"
    android:layout_height="wrap_content" android:lines="5" android:layout_centerInParent="true"
    android:gravity="top|left" android:inputType="textMultiLine"
    android:scrollHorizontally="false" android:minWidth="10.0dip"
    android:maxWidth="180dip" />

it will work


Now a day use of gravity start is best choise:

android:gravity="start"

For EditText (textarea):

<EditText
    android:id="@+id/EditText02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:lines="5"
    android:gravity="start"
    android:inputType="textMultiLine"
/>