里面nestedscrollview Recyclerview [英] Recyclerview inside nestedscrollview
问题描述
我有一个布局,是这样的。
I have a layout which is like this
TextView的1
TextView 1
2的TextView
TextView 2
3的TextView
TextView 3
的ImageView
ImageView
Recyclerview
Recyclerview
[项目1至10
垂直组织]
[item 1 to 10 organized vertically]
现在,当我滚动页面,整个页面必须滚动,而不是单独Recyclerview。
这是一个非常常见,在Android的老东西,我得到的解决方案是实现结果
<一href=\"http://stackoverflow.com/questions/26530685/is-there-an-addheaderview-equivalent-for-recyclerview?lq=1\">Is有一个addHeaderView相当于RecyclerView?
Now, when I am scrolling the page, the entire page must scroll, not the Recyclerview alone.
This is a very common and an old thing in android, the solutions I get is implementing the
Is there an addHeaderView equivalent for RecyclerView?
我不希望采用这种做法,因为它是一个相当哈克的解决方案。我觉得内部实现nestedscrollview可能会解决我的问题recyclerview,我会采取正确的方法呢?或者我应该用协调的布局?
任何帮助是非常AP preciated,你能不能也给我提供了一些链接,满足我的要求。
I don't want to follow this approach as it is quite a hacky solution. I feel implementing recyclerview inside nestedscrollview might solve my issue, am I taking the right approach? or should I be using coordinator layout? Any help is highly appreciated, can you also provide me some links that meet my requirements.?
推荐答案
我发现了此查询的解决方案。在此布局一看,
该想法是有一个
I found out the solution for this query. Have a look at this layout, The idea is to have a
CoordinatorLayout作为根
CoordinatorLayout as the root
- AppBar布局恰好是协调的直接子布局
--AppBar layout happens to be the direct child layout for Coordinator
主机相对布局,将有不同的TextView /单选按钮(要添加为头之类的话)
Host the relative layout that will have the different textview/radiobutton (that you want to add as a header kind of thing)
---关闭appbarlayout
---Close the appbarlayout
添加只是appbarlayout下方recyclerview。
Add the recyclerview just below the appbarlayout.
它会正常工作,检查出我已经使用,不要忘记添加应用程序的布局:在适当的地方行为
It will work fine, check out the layout that I have used and don't forget to add app:behavior in proper places.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<RelativeLayout
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_height="wrap_content"
android:id="@+id/relLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView"
android:layout_marginLeft="97dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="37dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton"
android:id="@+id/radioButton"
android:layout_below="@+id/textView"
android:layout_alignLeft="@+id/textView"
android:layout_marginTop="49dp"/>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_small"
android:layout_below="@+id/relLayout"
android:id="@+id/recyclerview_settings_list"
android:scrollbars="vertical"/>
</android.support.design.widget.CoordinatorLayout>
这篇关于里面nestedscrollview Recyclerview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!