1.导包design
2.主函数
public class CoordinatorLayoutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coordinator_layout);
}
}
3.主布局
<?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:id="@+id/coorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.animee.day11.CoordinatorLayoutActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="280dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapslayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:collapsedTitleGravity="left|top"
app:expandedTitleGravity="right|bottom"
app:expandedTitleMargin="10dp"
app:contentScrim="@color/colorAccent"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<ImageView
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="#00ffff"
app:layout_collapseMode="parallax"
android:scaleType="centerCrop"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_collapseMode="pin"
app:title="我是Toolbar">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@mipmap/ali"
android:scaleType="centerCrop"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>