CoordinatorLayout是一个增强型的FrameLayout。它的作用有两个

  1. 作为一个布局的根布局
  2. 最为一个为子视图之间相互协调手势效果的一个协调布局

代码如下:

<?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"非常重要,不然就黏到一块去了

最新文章

  1. HTML基础
  2. cnodejs社区论坛4--话题列表
  3. 第十一篇 Integration Services:日志记录
  4. poj1179
  5. Java BTrace实战(1)--BTrace的入门和使用
  6. Openjudge/Poj 1183 反正切函数的应用
  7. hdu 4715 Difference Between Primes 2013年ICPC热身赛A题 素数水题
  8. and的用法(&amp;)
  9. windows下搭建nginx+php+laravel开发环境(转)
  10. Hibernate 5 入门指南-基于映射文件
  11. java7 java MethodHandle解析
  12. ubuntu安装sublime-text
  13. H5的本地存储技术及其与Cookie的比较
  14. 关于WARN Dispatcher:68 - Could not find action or result报错
  15. 对象反序列化出现类型不匹配的情况(spring-boot-devtools)
  16. 网络安装OS(配置文件)
  17. 015PHP文件处理——文件处理flock 文件锁定 pathinfo realpath tmpfile tempname
  18. Linux下搭建gtk+2.0开发环境
  19. APUE 12.7 取消选项
  20. MySQL自定义排序

热门文章

  1. 动画——animation部分
  2. HDU 2209 翻纸牌游戏
  3. Hrbustoj 2266 Legendary Weights(辗转相除求最大公约数)
  4. android 市场发布应用小结
  5. android--listview设置高度
  6. CodeForces 678D Iterated Linear Function
  7. 优化のzen cart调用WordPress
  8. PHP程序员学习路线
  9. width为auto或者100%的区别
  10. PHP字节格式化