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

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

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

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

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

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

先看下效果圖:

詳解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://m.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://m.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://m.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久久,三上悠亚国产精品一区二区三区
伊伊综合在线| 亚洲午夜91| 久久高清国产| 99pao成人国产永久免费视频| 久久蜜桃av| 蜜臀av免费一区二区三区| 999久久久精品国产| 99精品综合| 蜜臀91精品国产高清在线观看| 在线视频观看日韩| 国产女优一区| 日韩制服丝袜先锋影音| 亚洲精品在线a| 亚洲三级av| 日韩精品乱码av一区二区| 日韩欧美中文字幕电影| 国产精品一区二区中文字幕| 欧美国产极品| 亚洲精品永久免费视频| 91精品国产自产在线观看永久∴ | 最新日韩av| 久久国产精品毛片| 97久久中文字幕| 国产极品一区| 国产传媒av在线| 日韩在线中文| 91精品福利| 亚洲精品在线二区| 久久三级毛片| 999精品色在线播放| 日韩精品一二三| 国产探花在线精品一区二区| 成人午夜网址| 91精品电影| 日本免费在线视频不卡一不卡二| 欧美黄色一区二区| 欧美亚洲二区| 日韩在线第七页| 视频一区二区中文字幕| 国产欧美日韩在线观看视频| 精品国产欧美日韩| 欧美精品一区二区久久| 亚洲狼人精品一区二区三区| 国产精品99久久久久久董美香| 成人国产精品久久| 99综合视频| 国产精品久一| 免费av一区二区三区四区| 国产一区二区三区成人欧美日韩在线观看| 偷拍精品精品一区二区三区| 欧美午夜不卡| 欧美影院精品| 久久九九国产| 日韩中文字幕| 日韩电影二区| 香蕉视频成人在线观看| 欧美aa在线视频| 自拍日韩欧美| 国产福利一区二区精品秒拍| 国户精品久久久久久久久久久不卡| 一区二区精彩视频| 国产 日韩 欧美 综合 一区| 亚洲丝袜美腿一区| sm捆绑调教国产免费网站在线观看 | 国产精品三p一区二区| 免费在线小视频| 97se亚洲| 在线亚洲国产精品网站| 欧美黄色一区| 免费精品视频最新在线| 国产成人精品三级高清久久91| 免费日韩av片| 午夜av不卡| 国产精选久久| 老司机精品久久| 日韩一区亚洲二区| 欧美激情综合| 日本成人在线不卡视频| 国产综合精品一区| 国产精品白浆| 婷婷成人av| 午夜精品一区二区三区国产| 国内精品亚洲| 日本成人在线一区| 黑丝一区二区三区| 在线观看精品| 美女精品久久| 国产亚洲精品精品国产亚洲综合| 亚洲欧洲一区二区天堂久久| 国产中文在线播放| 欧美激情 亚洲a∨综合| 日韩福利视频导航| 中文无码久久精品| 99国内精品| 激情视频一区二区三区| 9999国产精品| 精品久久美女| 欧美精品国产| 亚洲精品亚洲人成在线观看| 亚洲精品123区| 欧美性感美女一区二区| 国产高潮在线| 日产精品一区二区| 欧美精品aa| 国产日韩精品视频一区二区三区| 一二三区精品| 免费在线观看一区二区三区| 99国产精品视频免费观看一公开 | 国产欧美一区二区三区精品酒店 | 999国产精品永久免费视频app| 久久久久免费| 鲁大师精品99久久久| 欧美片第1页综合| 97成人超碰| 欧美日韩亚洲一区在线观看| 日韩国产91| 日本三级亚洲精品| 欧美日韩1区2区3区| 国产亚洲欧美日韩精品一区二区三区 | 国产一区成人| 国产偷自视频区视频一区二区| 国产一区亚洲| 捆绑调教美女网站视频一区| 欧美性www| 国产精品视频一区视频二区| 久久在线视频免费观看| 午夜精品成人av| 日韩久久视频| 亚洲一级少妇| 久久久777| 久久久精品久久久久久96| 韩国精品主播一区二区在线观看 | 日韩av中文字幕一区二区三区| 亚洲不卡视频| 久久激情av| 久久久久伊人| 91亚洲国产成人久久精品| 97在线精品| 欧美影院三区| 久久午夜精品一区二区| 亚洲一区二区三区四区电影 | 国产亚洲精品自拍| 亚洲精品麻豆| 国产精品主播在线观看| 精品一区二区三区视频在线播放| 国产一区不卡| 亚洲福利免费| 一区二区日韩免费看| 欧美另类中文字幕| 激情中国色综合| 国产韩日影视精品| 一区二区不卡| 久久久久伊人| 欧美1区免费| 亚洲日本欧美| 夜鲁夜鲁夜鲁视频在线播放| 国产精品老牛| 日韩影院精彩在线| 国产日韩欧美一区在线| 日韩成人a**站| 欧美一区二区三区激情视频| 免费日韩av片| 国产精品一区二区精品| 成人午夜亚洲| 亚洲精品1区| 国产精品一区二区三区av| 麻豆视频在线观看免费网站黄| 五月婷婷亚洲| 91国内精品| 日韩深夜视频| 亚洲在线一区| 麻豆精品国产91久久久久久| 久久久夜夜夜| 亚洲精品极品| 国产精品久久久久久久久妇女| 99国产精品99久久久久久粉嫩| 欧美一区不卡| 蜜臀国产一区| 日韩 欧美一区二区三区| 成人国产精品一区二区免费麻豆| 影音国产精品| 老司机免费视频一区二区| 蜜桃tv一区二区三区| 日本午夜精品| 欧美 日韩 国产精品免费观看| 日韩视频一二区| www.51av欧美视频| 蜜臀久久99精品久久久画质超高清| 欧美激情久久久久久久久久久| 亚洲第一精品影视| 久久av免费| 蜜桃免费网站一区二区三区| 精品久久久久中文字幕小说| 日本电影久久久| 欧美精品成人| 国产精品美女久久久浪潮软件| 欧美精品91| 亚洲一二三区视频| 日韩专区精品| 久久精品超碰|