安卓悬停标题栏

我是一个大二的学生,然后被叫去参加什么比赛,然后我看了一个APP的标题栏悬停效果挺好看的,然后我 想我能不能实现,后来发现我做好以后有一点卡顿,滑动阻尼太大,然后我因为这个耽搁了两天时间,不知道是因为什么原因导致的,我也找了很多网上的教程,发现都是这种问题,然后我找到了掘金上面的解释,CoordinatorLayout有bug,会导致阻尼太大,出现卡顿效果,现在贴出代码:

mainpage.xml代码

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

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

        android:id="@+id/lmd_app_bar_layout"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        app:elevation="0dp">

            android:id="@+id/lmd_toolbar"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            app:contentInsetLeft="0dp"

            app:contentInsetStart="0dp"

            app:layout_scrollFlags="scroll|enterAlways"

            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">


            android:id="@+id/lmd_tl_tablayout"

            android:layout_width="match_parent"

            android:layout_height="45dp"

            android:background="@android:color/white" />

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical"

        android:id="@+id/scrollView"

        app:layout_behavior="@string/appbar_scrolling_view_behavior">

                android:id="@+id/lmd_nsp_viewpager"

                android:layout_width="match_parent"

                android:layout_height="match_parent" />

include_mainpage代码:


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

    android:orientation="vertical"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="vertical"

  >

            android:id="@+id/recycler"

            android:layout_width="match_parent"

            android:layout_height="150dp"

            app:autoPlaying="true"

            app:centerScale="1.4"

            app:itemSpace="20"

            app:moveSpeed="1.8"

            app:showIndicator="true" />

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_below="@+id/recycler"

            android:background="@color/white"

            android:orientation="vertical"

            android:paddingBottom="8dp"

            android:paddingTop="5dp">

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal"

                android:weightSum="5">

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_1" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_2" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_3" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_4" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_5" />

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_marginBottom="3dp"

                android:orientation="horizontal"

                android:weightSum="5">

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="学习用品" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="运动器材" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="电器" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="美妆" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="服饰" />

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal"

                android:weightSum="5">

                    android:id="@+id/imageView"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_6" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_7" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_8" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_9" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_margin="3dp"

                    android:layout_weight="1"

                    android:src="@mipmap/pic_10" />

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal"

                android:weightSum="5">

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="小百货" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="游戏装备" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="复习书本" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="电子设备" />

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:gravity="center"

                    android:text="更多" />

            android:layout_width="match_parent"

            android:layout_height="10dp"

            android:background="#fafafa" />

最后我找到了解决办法:

          app:layout_scrollFlags="scroll|enterAlways",问题出现在这里,设置标志的问题;

然后的问题还有CoordinatorLayout最好存在一个scrollview,scrollview里面存在一个子布局,如果是rv,必须解决滑动冲突

效果图我不会加,动态的,希望见谅

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容