Android - EditText multiline forced to fill height

Lorenzo Sciuto picture Lorenzo Sciuto · Jun 20, 2012 · Viewed 9.6k times · Source

I need a EditText that fills in height my window. I'm using this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:inputType="textMultiLine"
    android:textColor="@android:color/white" />

</ScrollView>

But all I get is a one line EditText that will be longer and scrollable once I write something on multiline typing the return button. I know I can set the line number, but in this case it should work on different devices and every device (I guess) has different amount of lines.

How can I force it to fill the device in height?

Any tips?

Answer

Alex Kucherenko picture Alex Kucherenko · Jun 20, 2012

Try to use (without ScrollView):

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:textColor="@android:color/white" />