我是一個(gè)大二的學(xué)生蹬挺,然后被叫去參加什么比賽维贺,然后我看了一個(gè)APP的標(biāo)題欄懸停效果挺好看的,然后我 想我能不能實(shí)現(xiàn)巴帮,后來發(fā)現(xiàn)我做好以后有一點(diǎn)卡頓溯泣,滑動(dòng)阻尼太大,然后我因?yàn)檫@個(gè)耽擱了兩天時(shí)間榕茧,不知道是因?yàn)槭裁丛驅(qū)е碌睦伲乙舱伊撕芏嗑W(wǎng)上的教程,發(fā)現(xiàn)都是這種問題用押,然后我找到了掘金上面的解釋肢簿,CoordinatorLayout有bug,會(huì)導(dǎo)致阻尼太大蜻拨,出現(xiàn)卡頓效果池充,現(xiàn)在貼出代碼:
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="學(xué)習(xí)用品" />
? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? ? ? ? ? android:text="運(yùn)動(dòng)器材" />
? ? ? ? ? ? ? ? ? ? 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="復(fù)習(xí)書本" />
? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? ? ? ? ? android:text="電子設(shè)備" />
? ? ? ? ? ? ? ? ? ? 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",問題出現(xiàn)在這里缎讼,設(shè)置標(biāo)志的問題收夸;
然后的問題還有CoordinatorLayout最好存在一個(gè)scrollview,scrollview里面存在一個(gè)子布局休涤,如果是rv咱圆,必須解決滑動(dòng)沖突
效果圖我不會(huì)加,動(dòng)態(tài)的功氨,希望見諒