效果,手把手教你用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实现折叠效果
发布评论