滚动视图内的Recyclerview-如何滚动整个内容? [英] Recyclerview inside scrollview- How to scroll whole content?
问题描述
我在Scrollview中有Recyclerview
I am having Recyclerview inside Scrollview
<Scrollview
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/layoutStaticContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Static content.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
.
.
<LinearLayout>
//Dynamic content(newsfeed)
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
现在,在滚动时,layoutStaticContent会固定在顶部& recyclerview内容在底部独立滚动. 如何滚动整个内容,即(layoutStaticContent + recyclerview内容),以使只有1个scrollview? 我还尝试用Nestedscrollview替换scrollview,但没有成功.
Now while scrolling, layoutStaticContent stays fix on the top & recyclerview content scrolls independently in the bottom part. How to scroll the whole content i.e (layoutStaticContent + recyclerview content) such that there is only 1 scrollview? I also tried replacing scrollview with Nestedscrollview but no success.
推荐答案
使用android.support.v4.widget.NestedScrollView
然后在两个布局内
NestedScrollView
Use the android.support.v4.widget.NestedScrollView
then inside both layout
NestedScrollView
这篇关于滚动视图内的Recyclerview-如何滚动整个内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!