Android 嵌套的滚动视图元素不滚动
我在嵌套滚动视图中有相对布局,在相对布局下有查看寻呼机表格布局和回收器视图。我的问题是嵌套的滚动视图元素没有滚动视图页面固定在顶部,而回收器视图在视图页面下方滚动。我想在布局中滚动视图页面 下面是我的代码:Android 嵌套的滚动视图元素不滚动,android,android-layout,Android,Android Layout,我在嵌套滚动视图中有相对布局,在相对布局下有查看寻呼机表格布局和回收器视图。我的问题是嵌套的滚动视图元素没有滚动视图页面固定在顶部,而回收器视图在视图页面下方滚动。我想在布局中滚动视图页面 下面是我的代码: <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/
<android.support.v4.widget.NestedScrollView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/nobook"
android:src="@drawable/nobook"
android:layout_centerInParent="true"
android:visibility="gone"/>
<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:layout_below="@+id/homeOffers"
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:layout_below="@+id/indicator"
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>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
有人请让我知道如何获得所需的布局。任何帮助都将不胜感激
谢谢您可以更改父级布局并将ScrollView作为子级使用 您当前的布局:
{NestedScrollView}(它是您的父级)-->
{RelativeLayout}-->
{ProgressBar、
图像视图、
查看页面等) 将父级更改为相对布局后:
{RelativeLayout}(现在是您的新父布局。其他所有内容都保持不变)-->
{ScrollView}(以前是您的嵌套ScrollView)-->
{RelativeLayout}-->
{ProgressBar、
ImageView、
ViewPager等您可以更改父布局并将ScrollView用作子级 您当前的布局:
{NestedScrollView}(它是您的父级)-->
{RelativeLayout}-->
{ProgressBar、
图像视图、
查看页面等) 将父级更改为相对布局后:
{RelativeLayout}(现在是您的新父布局。其他一切都保持不变)-->
{ScrollView}(以前是您的嵌套ScrollView)-->
{RelativeLayout}-->
{ProgressBar,
ImageView,
ViewPager等}试试这个-app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”属性添加到SwipeRefreshLayout。尝试将此-app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”属性添加到SwipeRefreshLayout。尝试在回收视图中添加
app:layou behavior=“@string/appbar\u scrolling\u view\u behavior”
。您还可以尝试添加recyclerView.setNestedScrollingEnabled(false)代码>在你的代码中。应用程序:布局\u行为我已经在嵌套滚动视图中添加了。兄弟它不起作用…尝试在你的RecyclerView中添加App:layout\u行为=“@string/appbar\u scrolling\u view\u behavior”
。您还可以尝试添加recyclerView.setNestedScrollingEnabled(false)代码>在你的代码中。App:layout\u行为我已经在嵌套的滚动视图中添加了。兄弟,它不起作用…我已经按照你的建议更改了布局,但到目前为止运气不好。当我删除滑动刷新布局时,它可以正常工作,但在包含滑动刷新布局后,它停止滚动。我已经按照你的建议更改了布局,但到目前为止运气不好。如我所愿删除滑动刷新布局它工作正常,但在包含滑动刷新布局后它停止滚动不,它不工作实际上罪魁祸首是滑动刷新布局删除它后,一切正常,但当我添加它时,它停止滚动,但我需要在我的布局中包含滑动刷新布局。不,它不工作实际上罪魁祸首是删除后滑动刷新布局一切正常,但当我添加它时,它会停止滚动,但我需要在布局中包括滑动刷新布局。