我在ScrollView中有一个RecyclerView。当我尝试滚动到底部时,RecyclerView(子元素)会在父级开始滚动之前滚动到底部。但是,我想要它,父母应该在孩子开始滚动之前完全滚动。这是我的布局文件。有人能指导我怎么能实现这一目标?如何在父窗口(ScrollView)完全滚动之前禁用子窗口(RecyclerView)滚动
<RelativeLayout 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
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/user_activity_linear_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/blank_layout"
android:orientation="vertical">
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recently_watched_recycler_view"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/blank_layout"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
我觉得我应该警告你滚动视图内的滚动视图几乎总是会给你Android的问题,应该不惜一切代价避免 –
我已经阅读了很多这样的警告对scrollview内的滚动视图。为什么这被认为是一种不好的做法?我的用例需要我有这样的布局。 – Bhaskar
那么如果上面是你的实际布局,为什么不把'blank_layout'作为回收视图的第一项呢?这当然假设你想让回收者视图填充scrollview,通过你提供的xml,它看起来就像你一样。 如果不是这种情况,为什么它首先必须在scrollview中? –