简体   繁体   English

如何像Facebook一样滚动列表视图上方的布局

[英]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. 就像Facebook滚动封面时一样滚动封面。 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. 尽管在stackoverflow上有许多与此类似的问题,但没有一个得到真正的答案。

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 使用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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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