Domanda

I've a framelayout with a listview and a linearlayout (bottom bar) at the bottom of this. When expand the listview, I can't scroll properly because the linearlayout at the bottom has covered the child of listview.

I don't understand where is the problem...I would like separate the bottom bar from the listview.

This is my layout (possibly, can you optimize this layout?):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.robertot.timereport.com.robertot.timereport.pages.WeeklyStatFragment">

    <RelativeLayout
        android:id="@+id/rlList"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/listWeek"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>

    </RelativeLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        android:layout_gravity="bottom"
        style="@android:style/Widget.Holo.Light.ActionBar.Solid">

        <Spinner
            android:id="@+id/spnYearW"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="8dp"/>

        <Spinner
            android:id="@+id/spnMonthW"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"/>

        <ImageButton
            android:id="@+id/btnFilter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_search"
            android:background="@null"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"/>

    </LinearLayout>

</FrameLayout>

thanks!!

È stato utile?

Soluzione

The problem is your FrameLayout doesn't prevent your Views from overlapping, which is why your ListView appears below it. One solution, that wouldn't require you to change much, would be to put your bottom LinearLayout inside your RelativeLayout and use the alignParentBottom and layout_above attributes to position things:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.robertot.timereport.com.robertot.timereport.pages.WeeklyStatFragment">

    <RelativeLayout
        android:id="@+id/rlList"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/listWeek"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/bottom_linear" />


        <LinearLayout
            android:id="@+id/bottom_linear"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            android:layout_alignParentBottom="true"
            style="@android:style/Widget.Holo.Light.ActionBar.Solid">

            <Spinner
                android:id="@+id/spnYearW"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="8dp"/>

            <Spinner
                android:id="@+id/spnMonthW"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_gravity="center_vertical"/>

            <ImageButton
                android:id="@+id/btnFilter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_search"
                android:background="@null"
                android:layout_weight="1"
                android:layout_gravity="center_vertical"/>

        </LinearLayout>

    </RelativeLayout>

</FrameLayout>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top