0

Like the following layout shows, when the items in list are too much, more than one screen.

I can not see the following LinearLayout content when I drag down.

How to solve this problem?

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

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_below="@+id/list"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/UserIDStatic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/UserID" />
        .
        .
        .
    </LinearLayout>

</RelativeLayout>

Thanks in advance!

4

2 回答 2

0

change to this

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

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="100dp" >   <!-- use a definate dimension here -->
    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_below="@+id/list"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/UserIDStatic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/UserID" />
        .
        .
        .
    </LinearLayout>

</RelativeLayout>

or else put both ListView and LinearLayout in ScrollView

or as bellow comment

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
android:weightSum="1"
android:orientatio="verticle" >

        <ListView
            android:id="@+id/list"
           android:layout_weight="0.5"
            android:layout_width="match_parent"
            android:layout_height="0dp" >  
        </ListView>

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
             android:layout_weight="0.5"


            android:orientation="horizontal" >

            <TextView
                android:id="@+id/UserIDStatic"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/UserID" />
            .
            .
            .
        </LinearLayout>

    </LinearLayout>
于 2013-02-19T07:41:57.600 回答
0

There are two options comes in picture.

  1. Instead of Relative layout Use Vertical Linear layout with appropriate wieght to listview and inner linear layout (eg. 0.7 and 0.3)
  2. Use same Relative layout as above with inner LinearLayout to alignparentbottom = true and listview above="@innerLinearLayout" linearlayout.

This might solve your problem. Using specific height for listview might cause different look in UI for different sized screens.

于 2013-02-19T08:05:24.633 回答