Android multi line EditText

Today I will show how to create multi line EditText field in your android application.Let’s first create a EditText field:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
	<EditText
	    android:text="EditText01"
	    android:id="@+id/EditText01"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:lines="5">
	</EditText>
</LinearLayout>

Now add this android:lines=”5″

	    android:text="EditText01"
	    android:id="@+id/EditText01"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:lines="5">

And the result should be a multi line edit text.

As you can see the image the text is in the middle, let’s move it on the top of the EditText. Insert this row

android:gravity="top"

and voala, the text is on the top of the EditText.

Posted in Android, Java, Layout at March 13th, 2011. 1 Comment.