一.CoordinatorLayout是design包里功能最为强大的一个新控件,搭配其他控件可以实现比较复杂的动画和布局效果。
一.参考官方文档:CoordinatorLayout是一个作为顶级布局的Viewgroup,是一个加强版的framlayout,既然说了是framlayout,那么就要记住framlayout的特性,那就是CoordinatorLayout如果不使用
AppBarLayout,NestedScrollView那么他的控件就会重叠。可能会得不到你想要的结果
根据官方的谷歌文档,AppBarLayout目前必须是第一个嵌套在CoordinatorLayout里面的子view。
CoordinatorLayout还提供了layout_anchor和layout_anchorGravity属性一起配合使用,可以用于放置floating view,比如FloatingActionButton与其他View的相对位置。
<?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:background="@android:color/white"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background=&