繁体   English   中英

滑动刷新布局下的RecyclerView未显示在嵌套滚动视图中

[英]RecyclerView under Swipe refresh layout is not showing in nested scroll view

我在滚动视图下的活动中有视图寻呼机和recyclerview。我在刷卡刷新布局下使用recyclerview。我的问题是当我使用没有刷卡刷新布局的recyclerview时,它显示在布局中,如果我将其包装在刷卡刷新布局下它没有显示在布局中。

这是我的xml代码如下:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Home"
android:orientation="vertical"
android:id="@+id/linearHome"
android:paddingBottom="16dp"
android:layout_marginTop="10dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:layout_marginBottom="50dp">

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progress2"
    android:layout_centerInParent="true"/>

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

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

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:id="@+id/homeOffers"/>

    <android.support.design.widget.TabLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/indicator"
        app:tabGravity="center"
        app:tabIndicatorHeight="0dp"
        app:tabBackground="@drawable/tab_selector"/>

   <android.support.v4.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/refresh">

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

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

 </LinearLayout>

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

</RelativeLayout>

有人请让我知道如何实现所需的布局。 任何帮助,将不胜感激。

谢谢

尝试这个

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/linearHome"
    android:paddingBottom="16dp"
    android:layout_marginTop="10dp"
    android:paddingLeft="12dp"
    android:paddingRight="12dp"
    android:layout_marginBottom="50dp">

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progress2"
        android:layout_centerInParent="true"/>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="none">

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

            <androidx.viewpager.widget.ViewPager
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:id="@+id/homeOffers"/>

            <com.google.android.material.tabs.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/indicator"
                app:tabGravity="center"
                app:tabIndicatorHeight="0dp"
                />

            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:id="@+id/refresh">

                <androidx.recyclerview.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/recycle"/>

            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</RelativeLayout>

OUTPUT

在此处输入图片说明

暂无
暂无

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

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