如何在嵌套滚动视图中使用滑动刷新布局

时间:2018-12-04 12:46:47

标签: android swiperefreshlayout android-nestedscrollview

我想在NestedScrollView中使用SwipeRefreshLayout

这是我的代码

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layoutDirection="ltr"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/suggestion_for_follow_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.vistaapp.marcopolo.Custom.Views.SquareImageView
                android:id="@+id/img_hide_suggestion_for_follow_layout"
                android:layout_width="@dimen/_12size"
                android:layout_height="0dp"
                android:layout_gravity="right|top"
                android:layout_margin="@dimen/_8margin"
                app:srcCompat="@drawable/ic_cancel"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_suggestion_for_follow"
                android:layout_marginTop="@dimen/_8margin"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <View
                android:layout_marginTop="@dimen/_4margin"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/gray"/>

        </LinearLayout>

        <android.support.v4.widget.SwipeRefreshLayout
            android:layout_marginTop="@dimen/_4margin"
            android:id="@+id/homeSwipe"
            android:visibility="visible"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/homeRecycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </android.support.v4.widget.SwipeRefreshLayout>

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

问题是SwipeRefreshLayout和RecyclerView没有显示。但是当我用RecyclerView替换SwipeRefreshLayout时效果很好。

我该如何解决?

0 个答案:

没有答案