自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

模擬優(yōu)酷像關(guān)電視一樣的退出效果

移動開發(fā) Android
關(guān)電視效果即:要求屏幕瞬間白屏,.白色屏幕以勻加速或勻減速向中間擠壓,直至一條白線后消失不見,露出黑漆漆一片的黑色背景。本文介紹了如何實現(xiàn)這種效果。

其實所謂像關(guān)電視一樣的退出效果就是一個動畫而已,好吧,看到這里的朋友可以先自己想想,其實思路是很簡單的。

1.要求屏幕瞬間白屏。

2.白色屏幕以勻加速或勻減速向中間擠壓,直至一條白線后消失不見,整個過程大概200毫秒。

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

首先,布局文件的寫法。有很多種,最簡單的就是利用RelativeLayout或者FrameLayout為應(yīng)用首界面的根布局,如果應(yīng)用的背景色本身為黑色最好,就像優(yōu)酷一樣。如果應(yīng)用的背景色不為黑色,那么在根布局里寫一:

  1. <FrameLayout 
  2.       android:id="@+id/fl_off" 
  3.         android:layout_width="fill_parent" 
  4.         android:layout_height="fill_parent" 
  5.         android:visibility="gone" 
  6.          > 
  7.     <ImageView 
  8.         android:layout_width="fill_parent" 
  9.         android:layout_height="fill_parent" 
  10.         android:background="@color/text_black" /> 
  11.     <ImageView 
  12.           android:id="@+id/iv_off" 
  13.         android:layout_width="fill_parent" 
  14.         android:layout_height="fill_parent" 
  15.         android:background="@color/text_white"  
  16.          android:visibility="gone"/> 
  17. </FrameLayout> 

第一個ImageView為黑色的背景色,第二個為白色的背景色。

下面是動畫文件的寫法 res/anim/tv_off.xml:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <set android:shareInterpolator="false" 
  3. android:zAdjustment="top" 
  4.   xmlns:android="http://schemas.android.com/apk/res/android">
  5. <span></span> 
  6. <scale android:interpolator="@android:anim/accelerate_interpolator" 
  7. android:duration="200" 
  8. android:pivotX="50.0%" 
  9. android:pivotY="50.0%" 
  10. android:fromXScale="1.0" 
  11. android:toXScale="1.0" 
  12. android:fromYScale="1.0" 
  13. android:toYScale="0.0030" /> 
  14.     <scale android:interpolator="@android:anim/accelerate_interpolator" 
  15. android:duration="200" 
  16. android:pivotX="50.0%" 
  17. android:pivotY="50.0%" 
  18. android:startOffset="200" 
  19. android:fromXScale="1.0" 
  20. android:toXScale="0.0" 
  21. android:fromYScale="1.0" 
  22. android:toYScale="0.3" /> 
  23.     <alpha android:interpolator="@interpolator/accelerate_quint" 
  24. android:duration="400" 
  25. android:fillAfter="true" 
  26. android:fromAlpha="1.0" 
  27. android:toAlpha="0.0" 
  28. android:fillEnabled="true" /> 
  29. </set> 

這個很簡單,大家copy就行了。

因為動畫引用到了加速器,下面是加速器文件的寫法 res/interpolator/accelerate_quint.xml:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <accelerateInterpolator android:factor="2.5" 
  3.   xmlns:android="http://schemas.android.com/apk/res/android" /> 

這是一個勻加速的加速器,加速倍數(shù)為2.5。

責(zé)任編輯:徐川 來源: OSChina
相關(guān)推薦

2023-04-05 14:19:07

FlinkRedisNoSQL

2013-12-17 09:02:03

Python調(diào)試

2022-12-21 15:56:23

代碼文檔工具

2023-05-23 13:59:41

RustPython程序

2013-12-31 09:19:23

Python調(diào)試

2015-04-09 11:27:34

2015-03-16 12:50:44

2013-08-22 10:17:51

Google大數(shù)據(jù)業(yè)務(wù)價值

2021-05-20 08:37:32

multiprocesPython線程

2011-01-18 10:45:16

喬布斯

2012-06-08 13:47:32

Wndows 8Vista

2015-02-05 13:27:02

移動開發(fā)模塊SDK

2022-05-26 01:15:22

GitHub代碼快捷鍵

2021-08-27 06:41:34

Docker ContainerdRun&Exec

2016-10-08 00:24:53

httptcp實時

2022-11-24 12:22:39

2012-06-14 09:48:11

OpenStackLinux

2011-10-24 13:07:00

2012-03-21 10:15:48

RIM越獄

2021-09-07 10:29:11

JavaScript模塊CSS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號