使用CoordinatorLayout打造各种炫酷的效果

https://blog.csdn.net/gdutxiaoxu/article/details/52858598
使用CoordinatorLayout打造各种炫酷的效果

自定义Behavior —— 仿知乎,FloatActionButton隐藏与展示

NestedScrolling 机制深入解析

一步步带你读懂 CoordinatorLayout 源码

自定义 Behavior -仿新浪微博发现页的实现

ViewPager,ScrollView 嵌套ViewPager滑动冲突解决

自定义 behavior - 完美仿 QQ 浏览器首页,美团商家详情页

重磅消息:小编我开始运营自己的公众号了, 目前从事于 Android 开发,除了分享 Android开发相关知识,还有职场心得,面试经验,学习心得,人生感悟等等。希望通过该公众号,让你看到程序猿不一样的一面,我们不只会敲代码,我们还会。。。。。。

有兴趣的话可以关注我的公众号 Android 技术人(stormjun94),或者拿起你的手机扫一扫,期待你的参与

CoordinatorLayout简介
CoordinatorLayout是在 Google IO/15 大会发布的,遵循Material 风格,包含在 support Library中,结合AppbarLayout, CollapsingToolbarLayout等 可 产生各种炫酷的效果

CoordinatorLayout简介通常用来 干什么
Google官方地址

CoordinatorLayout is intended for two primary use cases:

As a top-level application decor or chrome layout

As a container for a specific interaction with one or more child views

简单来说就是

作为最上层的View
作为一个 容器与一个或者多个子View进行交互
下面我们一起先来看一下我们实现的效果图
动态图

结合ToolBar


结合ViewPager


结合ViewPager的视觉特差


AppBarLayout
它是继承与LinearLayout的,默认 的 方向 是Vertical

类型    说明
int SCROLL_FLAG_ENTER_ALWAYS    When entering (scrolling on screen) the view will scroll on any downwards scroll event, regardless of whether the scrolling view is also scrolling.
int SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED    An additional flag for ‘enterAlways’ which modifies the returning view to only initially scroll back to it’s collapsed height.
int SCROLL_FLAG_EXIT_UNTIL_COLLAPSED    When exiting (scrolling off screen) the view will be scrolled until it is ‘collapsed’.
int SCROLL_FLAG_SCROLL    The view will be scroll in direct relation to scroll events.
int SCROLL_FLAG_SNAP    Upon a scroll ending, if the view is only partially visible then it will be snapped and scrolled to it’s closest edge.
类型    说明
int SCROLL_FLAG_ENTER_ALWAYS    W((entering) / (scrolling on screen))下拉的时候,这个View也会跟着滑出。
int SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED    另一种enterAlways,但是只显示折叠后的高度。
int SCROLL_FLAG_EXIT_UNTIL_COLLAPSED    ((exiting) / (scrolling off screen))上拉的时候,这个View会跟着滑动直到折叠。
int SCROLL_FLAG_SCROLL    这个View将会响应Scroll事件
int SCROLL_FLAG_SNAP    在Scroll滑动事件结束以前 ,如果这个View部分可见,那么这个View会停在最接近当前View的位置
我们可以通过两种 方法设置这个Flag

方法一
 setScrollFlags(int) 
1
方法二
 app:layout_scrollFlags="scroll|enterAlways"
1
注意事项
AppBarLayout必须作为CoordinatorLayout的直接子View,否则它的大部分功能将不会生效,如layout_scrollFlags等。

首先我们先来看一下我们 效果图一是怎样实现的
代码
————————————————
版权声明:本文为CSDN博主「gdutxiaoxu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/gdutxiaoxu/article/details/52858598

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值