日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

詳解Android使用CoordinatorLayout+AppBarLayout+CollapsingToolbarLayou實現手指滑動效果

瀏覽:56日期:2022-09-24 09:28:59

CoordinatorLayout+AppBarLayout+CollapsingToolbarLayou實現手指滑動效果

如何使用 CoordinatorLayout+AppBarLayout+CollapsingToolbarLayou實現下面GIF圖中的效果,再展開的時候頭像處于紅白中間,根據收縮程度改變頭像的位置!底下的RecyclerView也跟隨這個移動,不會出現中間隔出一段距離!(僅提供源碼復制粘貼,很簡單的)

先看下效果圖:

詳解Android使用CoordinatorLayout+AppBarLayout+CollapsingToolbarLayou實現手指滑動效果

下面上代碼

XML布局代碼如下:

<?xml version='1.0' encoding='utf-8'?><LinearLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'> <android.support.design.widget.CoordinatorLayout android: android:layout_width='match_parent' android:layout_height='match_parent' android:clipChildren='false'> <android.support.design.widget.AppBarLayout android: android:layout_width='match_parent' android:layout_height='wrap_content' android:background='@color/cFF3523' android:clipChildren='false' app:elevation='0dp'> <android.support.design.widget.CollapsingToolbarLayoutandroid: android:layout_width='match_parent'android:layout_height='wrap_content'app:layout_scrollFlags='scroll|exitUntilCollapsed'><RelativeLayout android: android:layout_width='match_parent' android:layout_height='200dp' android:orientation='horizontal' app:layout_collapseMode='parallax' app:layout_collapseParallaxMultiplier='0.25'> <android.support.v7.widget.CardView android:layout_width='match_parent' android:layout_height='60dp' android:layout_centerVertical='true' android:layout_gravity='center' android:layout_marginLeft='15dp' android:layout_marginRight='15dp' app:cardCornerRadius='5dp' app:cardElevation='5dp'> <LinearLayout android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='horizontal'> <LinearLayoutandroid:layout_width='0dp'android:layout_height='match_parent'android:layout_weight='1'android:orientation='vertical'><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal|bottom' android:text='331' android:textColor='@color/c333333' android:textSize='16sp' /><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal' android:text='積分' android:textColor='@color/c333333' android:textSize='10sp' /> </LinearLayout> <Viewandroid:layout_width='0.7px'android:layout_height='40dp'android:layout_gravity='center_vertical'android:background='#727272'></View> <LinearLayoutandroid:layout_width='0dp'android:layout_height='match_parent'android:layout_weight='1'android:orientation='vertical'><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal|bottom' android:text='5' android:textColor='@color/c333333' android:textSize='16sp' /><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal' android:text='優惠卷' android:textColor='@color/c333333' android:textSize='10sp' /> </LinearLayout> <Viewandroid:layout_width='0.7px'android:layout_height='40dp'android:layout_gravity='center_vertical'android:background='#727272'></View> <LinearLayoutandroid:layout_width='0dp'android:layout_height='match_parent'android:layout_weight='1'android:orientation='vertical'><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal|bottom' android:text='0.00' android:textColor='@color/c333333' android:textSize='16sp' /><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal' android:text='代金卷' android:textColor='@color/c333333' android:textSize='10sp' /> </LinearLayout> <Viewandroid:layout_width='0.7px'android:layout_height='40dp'android:layout_gravity='center_vertical'android:background='#727272'></View> <LinearLayoutandroid:layout_width='0dp'android:layout_height='match_parent'android:layout_weight='1'android:orientation='vertical'><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal|bottom' android:text='3314' android:textColor='@color/c333333' android:textSize='16sp' /><TextView android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:gravity='center_horizontal' android:text='淘幣' android:textColor='@color/c333333' android:textSize='10sp' /> </LinearLayout> </LinearLayout> </android.support.v7.widget.CardView></RelativeLayout><RelativeLayout android:layout_width='match_parent' android:layout_height='50dp' android:background='@color/cFF3523' android:gravity='center_vertical' app:layout_collapseMode='pin'> <ImageView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginRight='10dp' android:layout_toLeftOf='@id/Fragment_ontstf_message' android:src='http://www.b3g6.com/bcjs/@mipmap/set' /> <ImageView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_alignParentRight='true' android:layout_marginRight='10dp' android:src='http://www.b3g6.com/bcjs/@mipmap/message' /></RelativeLayout><android.support.v7.widget.Toolbar android: android:layout_width='match_parent' android:layout_height='?attr/actionBarSize' app:contentInsetStart='0dp' app:layout_collapseMode='pin'> <LinearLayout android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='horizontal' android:padding='5dp'> <de.hdodenhof.circleimageview.CircleImageView android: android:layout_width='45dp' android:layout_height='45dp' android:layout_gravity='center_vertical' android:src='http://www.b3g6.com/bcjs/@mipmap/ic_launcher_round' /> <LinearLayout android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='0dp'android:layout_weight='1'android:layout_marginLeft='10dp'android:textSize='18sp' /> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='0dp'android:layout_weight='1'android:layout_marginLeft='10dp'android:layout_marginBottom='5dp'android:textSize='14sp' /> </LinearLayout> </LinearLayout></android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v7.widget.RecyclerView android: android:layout_width='match_parent' android:layout_height='match_parent' android:background='@color/c00000000' app:layout_behavior='@string/appbar_scrolling_view_behavior'></android.support.v7.widget.RecyclerView> </android.support.design.widget.CoordinatorLayout></LinearLayout>

JAVA代碼如下:

/** * 獲取控件信息 */ private void initView() { FragmentOntstfAppBar = (AppBarLayout) view.findViewById(R.id.Fragment_ontstf_AppBar); FragmentOntstfToolbar = (Toolbar) view.findViewById(R.id.Fragment_ontstf_Toolbar); FragmentOntstfPortrait = (CircleImageView) view.findViewById(R.id.Fragment_ontstf_portrait); FragmentOntstfName = (TextView) view.findViewById(R.id.Fragment_ontstf_name); FragmentOntstfIntroduce = (TextView) view.findViewById(R.id.Fragment_ontstf_introduce); FragmentOntstfCollapsingToolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.Fragment_ontstf_CollapsingToolbarLayout); FragmentOntstfSet = (ImageView) view.findViewById(R.id.Fragment_ontstf_set); FragmentOntstfMessage = (ImageView) view.findViewById(R.id.Fragment_ontstf_message); FragmentOntstfRecyclerView = (RecyclerView) view.findViewById(R.id.Fragment_ontstf_RecyclerView); FragmentOntstfCoordinatorLayout = (CoordinatorLayout) view.findViewById(R.id.Fragment_ontstf_CoordinatorLayout); FragmentOntstfRelativeLayout = (RelativeLayout) view.findViewById(R.id.Fragment_ontstf_RelativeLayout); setFragmentOntstfRecyclerView(); AppBar(); mPresenter.PselectUser(Userid); } /** * 最主要的代碼 * AppBar滑動效果 */ private void AppBar() { FragmentOntstfAppBar.setExpanded(true); FragmentOntstfAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int i) {float alpha = (float) Math.abs(i) / appBarLayout.getTotalScrollRange();if (alpha == 0) { CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); FragmentOntstfRecyclerView.setPadding(0,FragmentOntstfToolbar.getHeight() / 2,0,0); layoutParams.setMargins(0, 0, 0, (-FragmentOntstfToolbar.getHeight() / 2)); layoutParams.gravity = Gravity.BOTTOM; FragmentOntstfToolbar.setLayoutParams(layoutParams); FragmentOntstfCoordinatorLayout.setClipChildren(false);} else if (FragmentOntstfRelativeLayout.getHeight() - Math.abs(i * 1.0f) == FragmentOntstfToolbar.getHeight()) { FragmentOntstfCoordinatorLayout.setClipChildren(true);} else { int a = (int) ((FragmentOntstfToolbar.getHeight() / 2) * alpha); CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); FragmentOntstfRecyclerView.setPadding(0,FragmentOntstfToolbar.getHeight() / 2 - a,0,0); layoutParams.setMargins(0, 0, 0, -(FragmentOntstfToolbar.getHeight() / 2) - (-a)); layoutParams.gravity = Gravity.BOTTOM; FragmentOntstfToolbar.setLayoutParams(layoutParams); FragmentOntstfCoordinatorLayout.setClipChildren(false);} } }); }

這樣就完成了!

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Android
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
偷拍亚洲精品| 欧美国产亚洲精品| 理论片午夜视频在线观看| 国产精品毛片一区二区三区| 久久亚洲精精品中文字幕| 国产精品传媒麻豆hd| 日本亚洲不卡| av一区二区高清| 成人午夜网址| 女主播福利一区| 一区二区小说| 激情婷婷久久| 成人午夜亚洲| 老司机免费视频一区二区| 国产乱子精品一区二区在线观看| 国产欧美日韩精品一区二区三区| 精品一区二区三区中文字幕| 蜜桃91丨九色丨蝌蚪91桃色| 天堂资源在线亚洲| 日本美女一区| 国产视频欧美| 亚洲精品九九| 久久黄色影视| 国产精品亲子伦av一区二区三区| 国产探花一区| 免费精品一区| 韩国精品主播一区二区在线观看| 日韩精品永久网址| 日韩视频免费| 深夜福利亚洲| 久久三级毛片| 久久精品99久久无色码中文字幕| 1024精品久久久久久久久| 国产精品观看| 国产欧美日韩精品一区二区免费| 日韩美女国产精品| 国产精品羞羞答答在线观看| 国产精品videossex| 久久最新视频| 啪啪亚洲精品| 国产一区二区三区四区二区| 99久久www免费| 日韩精品第一| 91精品xxx在线观看| 夜夜精品视频| 在线日韩成人| 欧美激情视频一区二区三区免费| 精品九九在线| 久久精品1区| 国产欧美日韩影院| 国产日本久久| 三级在线看中文字幕完整版| 国产视频一区三区| 亚洲日本国产| 日韩黄色大片| 日韩二区三区在线观看| 美美哒免费高清在线观看视频一区二区| 久久精品二区三区| 麻豆精品久久久| 国产精品调教| 亚洲人成毛片在线播放女女| 日韩在线第七页| 国内不卡的一区二区三区中文字幕| 亚洲欧美久久| 欧美日韩国产探花| 久久久久久亚洲精品美女| 国产精品久久久久久久久久齐齐| 在线看片一区| 婷婷综合在线| 国产精品精品国产一区二区| 亚洲日本国产| 日韩欧美高清一区二区三区| 日韩精选在线| av一区在线| 亚洲精品动态| 在线国产精品一区| 国产情侣久久| 久久久成人网| 尤物精品在线| 欧美日韩99| 亚洲www啪成人一区二区| 亚洲欧美高清| 婷婷亚洲五月| 亚洲综合中文| 国产成人精选| 午夜在线观看免费一区| 日本成人在线一区| sm捆绑调教国产免费网站在线观看| 欧美成人基地| 国产一区成人| 麻豆91小视频| 欧美日韩中文一区二区| 四虎精品永久免费| 91欧美国产| 人人精品人人爱| 狠狠久久伊人中文字幕| 国产免费成人| 精品一区二区三区的国产在线观看| 欧美日韩国产观看视频| 蜜臀av一区二区三区| 日本一区二区免费高清| 韩国三级一区| 精品91福利视频| 中文字幕日韩欧美精品高清在线| 国产理论在线| 日本不卡一区二区| 欧美午夜精品一区二区三区电影| 日韩激情啪啪| 热久久久久久久| 久久精品国产www456c0m| 麻豆免费精品视频| 91福利精品在线观看| 在线亚洲激情| 久久免费大视频| 成人av三级| 黑人精品一区| 日韩中文影院| caoporn视频在线| 日本亚洲视频| 中文日韩欧美| 首页国产欧美久久| 国产一区成人| 美日韩精品视频| 亚洲一区av| 日韩三级一区| 91成人在线精品视频| 亚洲男女自偷自拍| 国产亚洲精品久久久久婷婷瑜伽| 久久青草久久| 一区在线免费观看| 男人的天堂久久精品| 亚洲一区二区三区中文字幕在线观看| 宅男噜噜噜66国产日韩在线观看| 亚洲精品a级片| 久久久久.com| 亚洲免费激情| 亚洲制服一区| 麻豆久久一区| 日韩三区免费| 久久亚洲精品伦理| 欧美在线黄色| 久久国产精品色av免费看| 国产精品777777在线播放| 国产一区二区色噜噜| 久久香蕉国产| 日韩精品一区二区三区免费视频 | 蜜桃视频在线网站| 美女精品一区| 亚洲精品乱码久久久久久蜜桃麻豆 | 中文字幕在线看片| 免费黄色成人| 久久黄色影视| 亚洲国产日韩欧美在线| 日韩视频1区| 九九九精品视频| 亚洲精品国产嫩草在线观看| 亚洲一区二区三区中文字幕在线观看| 国产日韩欧美一区二区三区在线观看 | 国产精品美女久久久| 日韩高清不卡一区| 九九色在线视频| 国产精品天天看天天狠| 亚洲欧美一区在线| 国产精品九九| 欧美中文日韩| 日韩大片在线播放| 91成人精品在线| 久久亚洲美女| 久久影院资源站| 亚洲1区在线观看| 久久久久久久欧美精品| 9久re热视频在线精品| 福利一区视频| 国产精品日韩精品在线播放| 亚洲一区日韩| 99精品网站| 国产中文一区| 欧美日韩精品免费观看视完整| 欧美片第1页综合| 日韩在线短视频| 日韩1区2区| 都市激情国产精品| 精品一区二区三区在线观看视频 | 成人亚洲欧美| 国产精品亲子伦av一区二区三区| 国产精品流白浆在线观看| 日韩一区二区三区精品| 亚洲免费专区| 日韩精品国产欧美| 四虎成人精品一区二区免费网站| 久久亚洲影院| 日韩免费精品| 精品视频免费| 国内自拍视频一区二区三区| 国产一区二区精品福利地址| 四虎8848精品成人免费网站| 色88888久久久久久影院| 久久影院一区| 综合五月婷婷| 久久爱www成人|