模拟优酷像关电视一样的退出效果

    很久没写博文了,最近为公司的应用做了一个像关电视一样的退出效果,也是看见优酷APP这样搞了,所以试着弄一弄,下面就由我来将这个退出效果全盘托出。

    其实所谓像关电视一样的退出效果就是一个动画而已,好吧,看到这里的朋友可以先自己想想,其实思路是很简单的。


    1.要求屏幕瞬间白屏。

    2.白色屏幕以匀加速或匀减速向中间挤压,直至一条白线后消失不见,整个过程大概200毫秒。

    3.露出黑漆漆一片的黑色背景。


    首先,布局文件的写法。有很多种,最简单的就是利用RelativeLayout或者FrameLayout为应用首界面的根布局,如果应用的背景色本身为黑色最好,就像优酷一样。如果应用的背景色不为黑色,那么在根布局里写一个


<FrameLayout
      android:id="@+id/fl_off"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
         >
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/text_black" />
    <ImageView
          android:id="@+id/iv_off"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/text_white" 
         android:visibility="gone"/>
</FrameLayout>


第一个ImageView为黑色的背景色,第二个为白色的背景色。

下面是动画文件的写法 res/anim/tv_off.xml


<?xml version="1.0" encoding="utf-8"?>
<set android:shareInterpolator="false" android:zAdjustment="top"
  xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:interpolator="@android:anim/accelerate_interpolator" android:duration="200" android:pivotX="50.0%" android:pivotY="50.0%" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="0.0030" />
    <scale android:interpolator="@android:anim/accelerate_interpolator" android:duration="200" android:pivotX="50.0%" android:pivotY="50.0%" android:startOffset="200" android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0" android:toYScale="0.3" />
    <alpha android:interpolator="@interpolator/accelerate_quint" android:duration="400" android:fillAfter="true" android:fromAlpha="1.0" android:toAlpha="0.0" android:fillEnabled="true" />
</set>


这个很简单,大家copy就行了。

因为动画引用到了加速器,下面是加速器文件的写法 res/interpolator/accelerate_quint.xml

<?xml version="1.0" encoding="utf-8"?>
<accelerateInterpolator android:factor="2.5"
  xmlns:android="http://schemas.android.com/apk/res/android" />
这是一个匀加速的加速器,加速倍数为2.5。

好了,关键的东西全都写出来了,加载动画我就不说了,各位看官如果觉得还行就点个赞吧!

转载于:https://my.oschina.net/freestyletime/blog/95517

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值