【问题标题】:RecycleView is not visible when its set inside a NestedScrollView in androidRecyclerView 在 android 的 NestedScrollView 中设置时不可见
【发布时间】:2017-08-15 05:50:50
【问题描述】:

如何在 NestedScrollView 中使用 RecyclerView?设置适配器后 RecyclerView 内容不可见。

无论如何,我已经尝试在 NestedScrollView 中使用 RecyclerView,方法是添加一个像 framelayout 或 relativelayout 这样的视图组作为 nestedscrollview 的单个子项,然后我在 framelayout 或 relativelayout 中添加了一个 recyclerview)

在此先感谢...

<android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorWhite">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v4.widget.NestedScrollView
                android:id="@+id/nestedView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/appbar"
                android:fillViewport="true"                                   
               app:layout_behavior="@string/appbar_scrolling_view_behavior">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/profile_bg_clound"
                    android:orientation="vertical">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="5dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_marginTop="5dp">

                        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
                            android:id="@+id/swipe_refresh_layout"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">


                            <android.support.v7.widget.RecyclerView
                                android:id="@+id/rv_driverRequests"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:orientation="horizontal"
                                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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


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



        </RelativeLayout>


    </android.support.design.widget.CoordinatorLayout>

【问题讨论】:

    标签: android android-recyclerview scrollview android-nestedscrollview nestedscrollview


    【解决方案1】:

    用这个替换你的 RecycleView...

    <com.app.view.CustomRecyclerView
            android:id="@+id/rv_driverRequests"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    

    希望这会奏效。

    【讨论】:

    • 什么是 CustomRecyclerView ?
    猜你喜欢
    • 1970-01-01
    • 2017-07-28
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多