简体   繁体   中英

relative layout and listview in relative which in scrollview android

There're an elements of textview, button and imageview..etc on the top of the layout,but the large of part has listview. It's required, when we scroll, top elemnts must scrolling too with listview.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.revolage.vkcommunity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/vk_white"
android:orientation="vertical"
tools:context="com.egay.borsh.fragments.MainActivity" >

<RelativeLayout
    style="@style/ActionBarStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin" >

    <RelativeLayout
        android:id="@+id/action_bar_relative_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/activity_vertical_margin" >

        ......
    </RelativeLayout>

    <com.costum.android.widget.PullAndLoadListView
        android:id="@+id/main_post_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/header_linear_layout" />
</RelativeLayout>

but so, nothing is scrolling.

For this scenario you need to use an expandable ListView. Its a list view thats always expanded. So you can put it inside ScrollView. For your pullAndReflesh custom list view, you should check an expandable and extend your class from that. You can find this class on google.

Why a listView inside scrollview?

Because sometimes you need to use a adapter which cant be used with a LinearLayout for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM