gpt4 book ai didi

android - 嵌套 ScrollView 中的 Recyclerview

转载 作者:行者123 更新时间:2023-11-29 17:26:17 25 4
gpt4 key购买 nike

我有一个这样的布局

TextView 1

TextView 2

TextView 3

ImageView

回收站 View

[项目 1 到 10垂直组织]

现在,当我滚动页面时,整个页面都必须滚动,而不仅仅是 Recyclerview。这是 android 中非常常见和古老的事情,我得到的解决方案是实现
Is there an addHeaderView equivalent for RecyclerView?

我不想采用这种方法,因为它是一种非常棘手的解决方案。我觉得在 nestedscrollview 中实现 recyclerview 可能会解决我的问题,我采取的方法是否正确?还是我应该使用协调器布局?非常感谢任何帮助,您能否也提供一些符合我要求的链接。?

最佳答案

我找到了这个查询的解决方案。看看这个布局,这个想法是有一个

CoordinatorLayout 作为根

--AppBar布局恰好是Coordinator的直接子布局

托管将具有不同 TextView /单选按钮的相对布局(您想添加为标题类的东西)

---关闭appbarlayout

在 appbar 布局下方添加 recyclerview。

它会正常工作,检查我使用的布局,不要忘记在适当的地方添加 app:behavior。

<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>

关于android - 嵌套 ScrollView 中的 Recyclerview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34483578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com