0
votes

So I want a linearLayout at the top of the screen that has 2 buttons, a linearLayout at the bottom that also has two buttons and a listView in the middle. The problem I'm running into is that the bottom linearLayout gets covered up if the listView gets too big. I'm telling the listView to wrap_content as it's layout_height because I want to do that...but I almost positive thats the reason the bottom linearLayout isn't showing. Here's the code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/topLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/importClasses"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            >
        </Button>

        <TextView
            android:id="@+id/title"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/Title"
            android:layout_weight="1"
            android:gravity="center_horizontal|center_vertical|center"
             >
        </TextView>

        <Button
            android:id="@+id/addClasses"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             />
      </LinearLayout>

    <ListView
        android:id="@+id/classList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/topLayout" >

    </ListView>

    <LinearLayout
        android:id="@+id/bottomLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/classList"
         >

        <Button
            android:id="@+id/Assignments"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            >
        </Button>

        <Button
            android:id="@+id/flashCards"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             />
    </LinearLayout>

</RelativeLayout>

Any suggestions?

2

2 Answers

1
votes

Set classList to be above bottomLayout and below topLayout.

Also set bottomLayout to layout_alignParentBottom="true", and topLayout layout_alignParentTop="true"

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:id="@+id/topLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" android:layout_alignParentTop="true">

    <Button
        android:id="@+id/importClasses"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        >
    </Button>

    <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/Title"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical|center"
         >
    </TextView>

    <Button
        android:id="@+id/addClasses"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
  </LinearLayout>


<ListView
    android:id="@+id/classList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottomLayout"
    android:layout_below="@+id/topLayout" >

</ListView>

<LinearLayout
    android:id="@+id/bottomLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

    <Button
        android:id="@+id/Assignments"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        >
    </Button>

    <Button
        android:id="@+id/flashCards"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
</LinearLayout>

0
votes

This should work, but you may need to change your RelativeLayout to LinearLayout.

And change the layout_height of your ListView to 0dp and add layout_weight="1" to it.