美文网首页
NestedScrollView+RecyclerView

NestedScrollView+RecyclerView

作者: SunnyLYummy | 来源:发表于2019-08-05 15:29 被阅读0次

NestedScrollView+RecyclerView解决嵌套滑动冲突相关问题,并且能解决EditText和键盘的问题。

Kotlin的项目,就有官方提供的 androidx.core.widget.NestedScrollView,直接包住RecyclerView组件就可以了。

还有更酷的效果使用,顶部可折叠的banner,可参考这个文章:https://www.cnblogs.com/anni-qianqian/p/6814061.html

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:fitsSystemWindows="true"

    tools:context="com.example.administrator.scroll4.MainActivity">

    <android.support.design.widget.AppBarLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content">

        <android.support.design.widget.CollapsingToolbarLayout

            android:layout_width="match_parent"

            android:layout_height="220dp"

            app:contentScrim="#000000"

            app:layout_scrollFlags="scroll">

            <TextView

                android:layout_width="match_parent"

                android:layout_height="match_parent"

                android:background="#987545"

                android:gravity="center"

                android:text="banner区域"

                android:textColor="#ffffff" />

        </android.support.design.widget.CollapsingToolbarLayout>

        <TextView

            android:layout_width="match_parent"

            android:layout_height="30dp"

            android:gravity="center"

            android:text="悬浮的部分" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <com.example.administrator.scroll4.MyListView

            android:id="@+id/lv"

            android:layout_width="match_parent"

            android:layout_height="match_parent" />

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

相关文章

网友评论

      本文标题:NestedScrollView+RecyclerView

      本文链接:https://www.haomeiwen.com/subject/icymdctx.html