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

编程入门 行业动态 更新时间:2024-10-10 20:13:34

android 折纸<a href=https://www.elefans.com/category/jswz/34/1770448.html style=效果,手把手教你用CoordinatorLayout实现折叠效果"/>

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

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

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=""

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:

更多推荐

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

本文发布于:2024-02-05 11:24:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1745126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:效果   手把手   教你用   android   CoordinatorLayout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!