我在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中? –