当前位置:网站首页>Analysis on the use of coordinatorlayout
Analysis on the use of coordinatorlayout
2022-06-10 13:46:00 【yechaoa】
CoordinatorLayout yes design Control in package , As an outer control, you can coordinate sub controls to achieve cool effects, etc .
compile 'com.android.support:design:25.4.0'stay android studio There is one of them. ScrollingActivity The template of
<?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.yechaoa.materialdesign.activity.ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_scrolling"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_dialog_email"/>
</android.support.design.widget.CoordinatorLayout>include:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.yechaoa.materialdesign.activity.ScrollingActivity"
tools:showIn="@layout/activity_scrolling">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="@string/large_text"/>
</android.support.v4.widget.NestedScrollView>The outer layer is CoordinatorLayout, And then there was AppBarLayout, Then there is the content area and FloatingActionButton
This AppBarLayout It has a fixed height , And then it's wrapped inside Toolbar,Toolbar The outer layer is CollapsingToolbarLayout, Is collapsible
CollapsingToolbarLayout The main parameter is app:layout_scrollFlags:
scroll : Want to trigger a slide event , This attribute must be added , No, it will stop at the top , such as Tablayout
exitUntilCollapsed : It means to slide to the end and fold at the top
enterAlways : It means sliding up and disappearing , Slide down to see
Toolbar main parameter app:layout_collapseMode:
pin : Fixed mode , It's fixed at the top when folded
parallax : Parallax mode , There will be a parallax effect when folding .
The effect is triggered only when the content area is slidable , So the outer layer of the content area is NestedScrollView,app:layout_behavior="@string/appbar_scrolling_view_behavior" Property triggers the sliding effect ,
So the content area needs to be slidable with app:layout_behavior Property to trigger the sliding effect , Switch to RecycleView add app:layout_behavior Properties are also possible
Figure II effect :
<?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.yechaoa.materialdesign.activity.TabViewPagerScrollActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="220dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/app_name"
app:toolbarId="@+id/toolbar">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/header"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
app:tabIndicatorColor="@color/red"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/black"
app:tabTextColor="@color/gray"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>github:https://github.com/yechaoa/MaterialDesign
边栏推荐
- 解决VMWareStation安装 tools 时 D:\setup.exe 找不到的问题
- Neuron newsletter 2022-05 | add 2 southbound drivers and 1 northbound application, and realize customized extension with Modbus TCP
- Google Earth Engine(GEE)——利用MODIS 的叶面积指数影像掩膜dem批量下载
- Multithreading killer ---countdownlatch & cyclicbarrier
- [笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用
- 5.8G微波雷达模块使用,5.8G微波雷达模块工作原理和介绍
- 【C语言】指针函数与函数指针、数组函数
- What happened when the legendary login prompt failed to connect to the server? How to solve it?
- 【云计算】多云管理平台和公有云两者之间是啥关系?
- Leetcode-57- insert interval
猜你喜欢

解决VMWareStation安装 tools 时 D:\setup.exe 找不到的问题

Comprehensive training of large projects

【无标题】

Smart campus security channel and video monitoring solution

【笔记】关于keil中的出现的编译映射内存不足的问题
![buuctf [Jupyter]notebook-rce](/img/fc/9c2047bdadb606b555e48f553fb1dd.png)
buuctf [Jupyter]notebook-rce

High performance practical Alibaba sentinel notes, in-depth restoration of Alibaba micro service high concurrency scheme

32. Simple test of raspberry pie serial port communication and ultrasonic module ranging

Ekuiper newsletter 2022-05 protobuf codec support, visual drag and drop writing rules
![[technical analysis] discuss the production process and technology of big world games - preliminary process](/img/8d/52cb98a617f690df310d6de5512ebc.png)
[technical analysis] discuss the production process and technology of big world games - preliminary process
随机推荐
About native SQL and database methods in PHP framework
eKuiper Newsletter 2022-05|protobuf 编解码支持、可视化拖拽编写规则
Pychart installation tutorial
buuctf [Discuz]wooyun-2010-080723
Kotlin练手,以登录为例,Anko简单使用
What is the p value of a gene?
Neuron Newsletter 2022 - 05 | ajout de 2 entraînements Sud et 1 Application Nord, mise en œuvre de l'extension personnalisée par Modbus TCP
Leetcode-57- insert interval
常见的自动化测试框架有哪些?上海软件测试公司安利
Comprehensive training of large projects
im即时通讯开发:进程被杀底层原理、APP应对被杀技巧
How to deal with the interview for the fresh senior graduates who want to self-study software testing?
buuctf [PHP]CVE-2019-11043
What happened when the legendary login prompt failed to connect to the server? How to solve it?
十款好用跨浏览器测试工具分享,好物值得收藏
移动app性能测试有哪些需要进行?性能测试报告如何收费?
如何定位游戏发热问题
The relocation of Apple's production line shows that 5g industrial interconnection and intelligent manufacturing have limited help for manufacturing in China
Let resources flow freely in the cloud and locally
【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结