日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > Android UI開發第四十三篇――使用Property Animation實現墨跡天氣3.0引導界面及動畫實現

Android UI開發第四十三篇――使用Property Animation實現墨跡天氣3.0引導界面及動畫實現

來源:程序員人生   發布時間:2014-09-17 19:48:31 閱讀次數:4740次
前面寫過墨跡天氣3.0引導界面及動畫實現,里面完美實現了動畫效果,那一篇文章使用的View Animation,這一篇文章使用的Property Animation實現。Property Animation是Android3.0以后新增的動畫庫。

這篇文章的源碼以及效果在github。

    實現墨跡天氣向上滑動的viewpager使用的開源庫ViewPager-Android。ViewPager-Android開源庫設置app:orientation定義滑動方向。


    墨跡天氣引導界面共有4個視圖,先看一下:(這里引入的圖片都是實現后的,截圖都是靜態圖,運行程序看動畫效果)。

               

圖一                                                                                          圖二

   

               

圖三                                                                                        圖四



    墨跡天氣的引導界面使用的無非是移動、漸變、縮放、轉動或者其中幾個的組合。我們介紹其中的部分實現。


1、縮放動畫


    首先是圖一的“極低耗電”使用了一個縮放效果,使用Property Animation實現如下:

    xml動畫文件:

   

[html] view plaincopyprint?
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:ordering="together" > 
  4.  
  5.     <objectAnimator 
  6.         android:duration="1000" 
  7.         android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
  8.         android:propertyName="scaleX" 
  9.         android:valueFrom="1.0" 
  10.         android:valueTo="1.1" 
  11.         android:valueType="floatType" > 
  12.     </objectAnimator> 
  13.     <objectAnimator 
  14.         android:duration="1000" 
  15.         android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
  16.         android:propertyName="scaleY" 
  17.         android:valueFrom="1.0" 
  18.         android:valueTo="1.1" 
  19.         android:valueType="floatType" > 
  20.     </objectAnimator> 
  21.  
  22. </set> 
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together" > <objectAnimator android:duration="1000" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:propertyName="scaleX" android:valueFrom="1.0" android:valueTo="1.1" android:valueType="floatType" > </objectAnimator> <objectAnimator android:duration="1000" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:propertyName="scaleY" android:valueFrom="1.0" android:valueTo="1.1" android:valueType="floatType" > </objectAnimator> </set>

java使用:

[java] view plaincopyprint?
  1. animation1=(AnimatorSet)AnimatorInflater.loadAnimator(PropertyAnimActivity.this,   
  2.                 R.animator.tutorail_rotate);  
  3.         LinearInterpolator lin = new LinearInterpolator(); 
  4.         animation1.setInterpolator(lin); 
  5.         t1_icon2.setVisibility(View.VISIBLE); 
  6.          
  7.         animation1.setTarget(t1_icon2);   
  8.         animation1.start();  
animation1=(AnimatorSet)AnimatorInflater.loadAnimator(PropertyAnimActivity.this, R.animator.tutorail_rotate); LinearInterpolator lin = new LinearInterpolator(); animation1.setInterpolator(lin); t1_icon2.setVisibility(View.VISIBLE); animation1.setTarget(t1_icon2); animation1.start();


2、移動漸變組合動畫


    圖一中下面的箭頭使用了移動漸變組合動畫,實現如下:

    xml文件:

[html] view plaincopyprint?
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:ordering="together" > 
  4.  
  5.     <!-- 
  6.     可以包含<objectAnimator>, <valueAnimator>,<set>項 
  7.     屬性:android:ordering=["together" | "sequentially"],子集執行順序 
  8.     sequentially    Play animations in this set sequentially 
  9.     together (default)  Play animations in this set at the same time. 
  10.     --> 
  11.  
  12.     <set 
  13.         xmlns:android="http://schemas.android.com/apk/res/android" 
  14.         android:ordering="together" > 
  15.         <objectAnimator 
  16.             android:duration="1000" 
  17.             android:propertyName="translationX" 
  18.             android:repeatCount="infinite" 
  19.             android:repeatMode="reverse" 
  20.             android:valueFrom="0" 
  21.             android:valueTo="0" 
  22.             android:valueType="floatType" > 
  23.         </objectAnimator> 
  24.         <objectAnimator 
  25.             android:duration="1000" 
  26.             android:propertyName="translationY" 
  27.             android:repeatCount="infinite" 
  28.             android:repeatMode="reverse" 
  29.             android:valueFrom="-15" 
  30.             android:valueTo="20" 
  31.             android:valueType="floatType" > 
  32.         </objectAnimator> 
  33.     </set> 
  34.  
  35.     <objectAnimator 
  36.         android:duration="1000" 
  37.         android:propertyName="alpha" 
  38.         android:repeatCount="infinite" 
  39.         android:valueFrom="1.0" 
  40.         android:valueTo="0.3" 
  41.         android:valueType="floatType" > 
  42.     </objectAnimator> 
  43.     <!-- 
  44.    objectAnimator: 
  45.      
  46.         android:propertyName 
  47.             對view可以設置一下值: 
  48.                translationX and translationY:  
  49.                    These properties control where the View is located  
  50.                    as a delta from its left and top coordinates which  
  51.                    are set by its layout container. 
  52.                rotation, rotationX, and rotationY:  
  53.                    These properties control the rotation  
  54.                    in 2D (rotation property) and 3D around the pivot point. 
  55.                scaleX and scaleY:  
  56.                    These properties control the 2D scaling of a View around  
  57.                    its pivot point. 
  58.                pivotX and pivotY:  
  59.                    These properties control the location of the pivot point,  
  60.                    around which the rotation and scaling transforms occur.  
  61.                    By default, the pivot point is located at the center of  
  62.                    the object. 
  63.                x and y:  
  64.                    These are simple utility properties to describe  
  65.                    the final location of the View in its container,  
  66.                    as a sum of the left and top values and translationX  
  67.                    and translationY values. 
  68.                alpha:  
  69.                    Represents the alpha transparency on the View.  
  70.                    This value is 1 (opaque) by default, with a value of 0  
  71.                    representing full transparency (not visible). 
  72.                     
  73.                還可以設置"backgroundColor"等值 
  74.                     
  75.         android:valueTo 
  76.             float, int, or color. Required. The value where the animated property ends.  
  77.             Colors are represented as six digit hexadecimal numbers (for example, #333333). 
  78.          
  79.         android:valueFrom 
  80.             float, int, or color. The value where the animated property starts. If not specified,  
  81.             the animation starts at the value obtained by the property's get method.  
  82.             Colors are represented as six digit hexadecimal numbers (for example, #333333). 
  83.          
  84.         android:duration 
  85.             int. The time in milliseconds of the animation. 300 milliseconds is the default. 
  86.          
  87.         android:startOffset 
  88.             int. The amount of milliseconds the animation delays after start() is called.   
  89.          
  90.         android:repeatCount:重復次數 
  91.             說明: 
  92.             infinite:循環執行, 
  93.             具體正整數表示循環次數 
  94.              
  95.         android:repeatMode:重復模式, 
  96.             說明: 
  97.                 restart:重新從頭開始執行 
  98.                 reverse:反方向執行 
  99.                  
  100.         android:valueType 
  101.            Keyword. Do not specify this attribute if the value is a color.  
  102.            The animation framework automatically handles color values 
  103.             
  104.            intType: Specifies that the animated values are integers 
  105.            floatType (default): Specifies that the animated values are floats 
  106.     --> 
  107.  
  108. </set> 
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together" > <!-- 可以包含<objectAnimator>, <valueAnimator>,<set>項 屬性:android:ordering=["together" | "sequentially"],子集執行順序 sequentially Play animations in this set sequentially together (default) Play animations in this set at the same time. --> <set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together" > <objectAnimator android:duration="1000" android:propertyName="translationX" android:repeatCount="infinite" android:repeatMode="reverse" android:valueFrom="0" android:valueTo="0" android:valueType="floatType" > </objectAnimator> <objectAnimator android:duration="1000" android:propertyName="translationY" android:repeatCount="infinite" android:repeatMode="reverse" android:valueFrom="-15" android:valueTo="20" android:valueType="floatType" > </objectAnimator> </set> <objectAnimator android:duration="1000" android:propertyName="alpha" android:repeatCount="infinite" android:valueFrom="1.0" android:valueTo="0.3" android:valueType="floatType" > </objectAnimator> <!-- objectAnimator: android:propertyName 對view可以設置一下值: translationX and translationY: These properties control where the View is located as a delta from its left and top coordinates which are set by its layout container. rotation, rotationX, and rotationY: These properties control the rotation in 2D (rotation property) and 3D around the pivot point.
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 91国偷自产一区二区使用方法 | 最近免费中文字幕 | 国产成人精品999在线观看 | 久久久久久美女 | 精品一区二区在线视频 | 国产性生活大片 | 亚洲视频在线免费观看 | 国产二区精品在线观看 | 国产91成人在在线播放 | www国产亚洲精品久久网站 | 免费看成人吃奶视频在线 | 夜夜视频 | 欧美国产日韩视频 | 欧美黄视频 | 亚洲免费视频在线 | 日韩中文字幕网址 | 91久久国产综合久久 | 亚洲欧美日韩精品久久亚洲区 | 麻豆国产一区 | 五月激情丁香 | 色片免费观看 | 久久鬼| 一区二区三区 在线 | 欧美电影一区 | 亚洲福利片 | 久久精品| 日韩av手机免费在线观看 | 中文字幕 国产 | 国产激情在线视频 | 欧美视频一区二区在线观看 | 黄色av免费观看 | 中国一级特黄真人毛片免费观看 | 国产 日韩 欧美 在线 | 日本成人免费在线 | 国产一区二区精品在线 | 国产一区99| 中文字幕播放 | 麻豆一区 | 免费中文字幕av | 精品无码久久久久久国产 | 成人日韩精品 |