I’m trying to create a simple layout but can’t find a propper way to do it. Layout should have 3 elements: TextView on top, EditText (with scrollview) in the middle and button on bottom.
I made this code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="1"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_weight="0.97"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/linearLayout18"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text:"
android:gravity="center_vertical"/>
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/txtMessage"
android:text=""/>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_weight="0.03"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:orientation="vertical">
<Button
android:text="Next"
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
But it gives me layout like this:
As you can see the problem is that EditText won’t take all available vertical space (all the way to button). How to solve this?
Just use
android:fillViewport="true"in yourScrollView