简体   繁体   中英

how to scroll the layout above listview like facebook

I want to scroll the layout am using above the list view to scroll with it when i scroll down. Like Facebook scrolls the cover when we scroll on out profile. I have tried placing them into relative output and using scroll view but unfortunately nothing works. Despite the fact that there are many questions similar to this on stackoverflow none of them has been answered authentically.

Example layout :

<LinearLayout
                 android:id="@+id/layout1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" 
                android:background="#000000">
            <LinearLayout
                android:id="@+id/profilefraglayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" 
                android:background="#000000">
            </LinearLayout>
            <ListView
                android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >
            </ListView>
    </LinearLayout>

use ScrollView

<LinearLayout 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"
 android:orientation="vertical">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
>

   <include
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        layout="@layout/custom_layout" />

</ScrollView>

<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>

</LinearLayout>

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