CoordinatorLayout的使用

匿名 (未验证) 提交于 2019-12-03 00:27:02

CoordinatorLayoutGradleSupport Design Library

compile 'com.android.support:design:22.2.1'

CoordinatorLayoutBehaviorBehaviorBehaviorChildDependencyChildViewViewCoordinatorLayoutViewChildCoordinatorLayoutViewDependencyChildViewgifViewDependencyViewChildViewViewDependencyViewChildViewBehaviorChildBehavior

app:layout_behavior="com.meizu.coordinatorlayoutdemo.RotateBehavior"/>

BehaviorCoordinatorLayout.Behavior<T>,TViewChildBehavior

publicbooleanlayoutDependsOn(CoordinatorLayout parent, Button child, View dependency) {

//如果dependency是view的实例,说明它就是我们所需要的Dependency

returninstanceof

}

//每次dependency位置发生变化,都会执行onDependentViewChanged方法

@Override

publicbooleanonDependentViewChanged(CoordinatorLayout parent, Button btn, View dependency) {

}

Behavior

AppBarLayout

LinearLayoutVerticalAppBarLayoutCoordinatorLayoutViewlayout_scrollFlags

layout_scrollFlags="scroll|enterAlways,
layout_scrollFlags=scrollView
layout_scrollFlags=“enterAlways” View
toolBar toolBar

app:layout_scrollFlags="scroll|snap"
layout_scrollFlags=scrollView
layout_scrollFlags=“snap” ScrollViewViewView

CollapsingToolbarLayoutFrameLayout

,CollapsingToolbarLayout,AppBarLayout

app:layout_collapseMode="parallax",表示视差效果app:layout_collapseMode="pin",当这个控件到达 CollapsingToolbarLayout的底部的时候,会代替整个CollapsingToolbarLayout显示


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!