哈哈,差不多有一个礼拜没有更新,去广东那边旅游了四五天所以就没有更新,接下来就要恢复正常了,又要开始学习了。今天带来的是关于CoordinatorLayout的应用,模仿着支付宝做了一个界面,先看一下效果图吧。
实现了和支付宝一样的上滑收缩和变化的功能。核心使用的就是今天要说的coordinatorLayout。CoordinatorLayout作为“super-powered FrameLayout”基本实现两个功能:
1、作为顶层布局
2、调度协调子布局
就我的大白话来说就是协调子View之间动作的一个父View,通过Behavior来给子view实现交互的。
另外使用CoordinatorLayout需要在Gradle加入Support Design Library
compile 'com.android.support:design:24.2.1'
然后先看一下主布局。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.sp.coordinatortry.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/color1984D1"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:title=" ">
<include layout="@layout/shenghuo_head1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginBottom="25dp"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.8"/>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetLeft=