FABRevealLayout布局动画

本文分享了一个在优快云上可供下载的资源案例,包括了文件的下载链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

整理的demo

效果如图



下载地址  http://download.youkuaiyun.com/detail/qq_34709056/9858187

浮动按钮(Floating Action Button)与视图切换的动画效果。项目地址:https://github.com/truizlop/FABRevealLayout 效果图:使用说明:FABRevealLayout用起来很简单。你只需在布局里面包含一个Design Support Library的FloatingActionButton以及两个view(这里称为主view与次view)。FABRevealLayout会自动摆放它们的位置并提供两个view之间的动画切换功能。<com.truizlop.fabreveallayout.FABRevealLayout     android:id="@ id/fab_reveal_layout"     android:layout_width="match_parent"     android:layout_height="@dimen/fab_reveal_height"     >       <android.support.design.widget.FloatingActionButton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         app:backgroundTint="@color/some_color"         android:src="@drawable/some_drawable"         />       <RelativeLayout         android:id="@ id/main_view"         android:layout_width="match_parent"         android:layout_height="match_parent">           ...     </RelativeLayout>       <RelativeLayout         android:id="@ id/secondary_view"         android:layout_width="match_parent"         android:layout_height="match_parent">           ...     </RelativeLayout>   </com.truizlop.fabreveallayout.FABRevealLayout>请注意次view背景必须是透明的,那样color animation才能正常工作。更多动画在过渡效果发生期间,如果你想让FABRevealLayout里面的元素也显示动画,或者需要其他的任何操作,你可以注册一个listener。private void configureFABReveal(FABRevealLayout fabRevealLayout) {     fabRevealLayout.setOnRevealChangeListener(new OnRevealChangeListener() {         @Override         public void onMainViewAppeared(FABRevealLayout fabRevealLayout, View mainView) {}           @Override         public void onSecondaryViewAppeared(final FABRevealLayout fabRevealLayout, View secondaryView) {}     }); }或者,要主动出发reveal于隐藏动画的话,你可以用如下方法:fabRevealLayout.revealMainView(); fabRevealLayout.revealSecondaryView();局限目前,要让动画正常工作,FABRevealLayout内部的主view和次view高度必须相同。
实现页面间波纹动画效果切换。可配合Activity或Fragment间切换。如果是Activity间切换,你需要将Activity背景设为透明,否则影响切换效果。而Fragment间就不存在这样的问题,可以实现流畅、无缝切换。项目地址:https://github.com/kyze8439690/RevealLayout 效果图:单击上面的"下载源码"按钮,可下载完整demo。一个是官方的demo,比较复杂, 一个是我简化的。如何使用将被跳转页的根布局改为<me.yugy.github.reveallayout.RevealLayout><me.yugy.github.reveallayout.RevealLayout xmlns:android="http://schemas.android.com/apk/res/android"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:id="@ id/reveal_layout">     ...你的页面的View      </me.yugy.github.reveallayout.RevealLayout>2. 得到RevealLayoutmRevealLayout = (RevealLayout)this.findViewById(R.id.reveal_layout);3. 为RevealLayout的ViewTreeObserver添加监听ViewTreeObserver.OnGlobalLayoutListener, 在监听中调用show()来启动进入页面波动动画。mRevealLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {             @Override             public void onGlobalLayout() { //                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { //                    mRevealLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); //                } else { //                    mRevealLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); //                }                 mRevealLayout.postDelayed(new Runnable() {//设置了50毫秒的延时                     @Override                     public void run() {                         mRevealLayout.show();                     }                 }, 50);             }         });你可以调用mRevealLayout.hide()来启动关闭页面波动动画。如果是Activity间跳转,你还需要调用finish()才能退出页面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值