CoordinatorLayout学习笔记
2024-10-15 07:48:53
CoordinatorLayout是一个增强型的FrameLayout。它的作用有两个
- 作为一个布局的根布局
- 最为一个为子视图之间相互协调手势效果的一个协调布局
代码如下:
<?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"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways" /> <android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill" /> </android.support.design.widget.AppBarLayout> <!--可滑动的布局内容-->
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_discuss"
android:layout_gravity="bottom|end"/> </android.support.design.widget.CoordinatorLayout>
因为这是一个FrameLayout,所以在布局的时候app:layout_behavior="@string/appbar_scrolling_view_behavior"非常重要,不然就黏到一块去了
最新文章
- HTML基础
- cnodejs社区论坛4--话题列表
- 第十一篇 Integration Services:日志记录
- poj1179
- Java BTrace实战(1)--BTrace的入门和使用
- Openjudge/Poj 1183 反正切函数的应用
- hdu 4715 Difference Between Primes 2013年ICPC热身赛A题 素数水题
- and的用法(&;)
- windows下搭建nginx+php+laravel开发环境(转)
- Hibernate 5 入门指南-基于映射文件
- java7 java MethodHandle解析
- ubuntu安装sublime-text
- H5的本地存储技术及其与Cookie的比较
- 关于WARN Dispatcher:68 - Could not find action or result报错
- 对象反序列化出现类型不匹配的情况(spring-boot-devtools)
- 网络安装OS(配置文件)
- 015PHP文件处理——文件处理flock 文件锁定 pathinfo realpath tmpfile tempname
- Linux下搭建gtk+2.0开发环境
- APUE 12.7 取消选项
- MySQL自定义排序