Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a TextView occupy all free space in the middle?

Tags:

android

layout

I'm writing an Android app, I have a EditText on top, several bottoms on bottom. I implemented this using Relative layout.

In the middle I have a TextView. But the problem is that it occupies all the space under the EditText including the space where the buttons are.

I want it to end right before the buttons. How can I do that?

enter image description here

like image 989
Alex Avatar asked Jun 03 '11 11:06

Alex


2 Answers

I would do that layout like this:

<RelativeLayout android:width="fill_parent"
  android:height="fill_parent">

  <EditText android:id="@+id/top_Layout"
    android:width="fill_parent"
    android:height="wrap_content"
    android:layout_alignParentTop="true"/>

  <LinearLayout android:id="@+id/buttons"
    android:width="fill_parent"
    android:height="wrap_content"
    android:layout_alignParentBottom="true"/>

  <RelativeLayout android:id="@+id/center_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/top_Layout"
    android:layout_above="@id/buttons"/>

</RelativeLayout>
like image 199
Macarse Avatar answered Sep 28 '22 08:09

Macarse


Put your buttons in a linearLayout(orientation=horizontal). Use layout_alignParentBottom to put this linearLayout at the bottom. Similarly, use layout_alignParentTop for your editText.

like image 38
Timuçin Avatar answered Sep 28 '22 07:09

Timuçin