android 折纸效果,手把手教你用CoordinatorLayout实现折叠效果

其实在很早之前有用到过CoordinatorLayout,因为自己也看过相关的源码,主要是利用了behavior来通过下面的view来滑动上面的view,很大程度上方便了开发者来实现折叠的效果,废话不多说,咱们今天拿实际项目的案例,打造一个折叠的效果:

83e4cdaf173d

simple.gif

书架里面的签到部分是受下面一部分拖拽控制的,这也是CoordinatorLayout的特性,通过下面能滑动的view来实现上面一部分的view滑动。咱们看看该效果是怎么实现的:

将项目的style设置如下:

@color/colorPrimary

@color/colorPrimaryDark

@color/colorAccent

false

true

将activity设置如下模式,用到了statusbar库

StatusBarUtil.setTranslucentForImageViewInFragment(MainActivity.this, 0, null);

主要看看BookShelfFragment代码

布局:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/content"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:visibility="gone">

android:id="@+id/AppFragment_AppBarLayout"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@color/white"

app:elevation="0dp">

android:layout_width="match_parent"

android:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值