多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

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

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

來源:程序員人生   發布時間:2014-09-17 19:48:31 閱讀次數:4724次
前面寫過墨跡天氣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.
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 欧美性美 | 亚洲欧美一级夜夜爽w | 乡下女色又黄一级毛片 | 欧美精品一级毛片 | 国产亚洲精品欧美一区 | 欧美精品18videose×性欧美 | 波多野结衣高清videossex | 欧美free嫩交video| 夜夜嗨视频| 国产高清吃奶成免费视频网站 | 欧美 xx性 在线 | 久久99久久99精品免观看麻豆 | 亚洲福利网址 | 久久性久久性久久久爽 | 成人性毛片 | 亚洲系列动漫卡通 | 一级做a爱免费观看视频 | 日本乱人伦片中文三区 | 亚洲国产成人精品女人久久久 | 91真人毛片一级在线播放 | 婷婷五月在线视频 | 精品欧美一区二区三区四区 | jizz中国18| 欧美va在线观看 | 欧美性猛交xxxx乱大交 | 欧美日韩国产一区二区三区 | 456免费视频| 国产精品欧美日韩一区二区 | 老司机午夜精品视频 | 久久亚洲国产成人影院 | 顶级欧美做受xxx000 | 川上优最新中文字幕不卡 | 日本96在线精品视频免费观看 | 日本护士xxx人 | 亚洲春色第一页 | 羞羞视频免费入口网站 | 曰本人一级毛片免费完整视频 | 国产第一页在线播放 | 免费网站在线观看国产v片 免费网站在线看 | 激情视频在线观看网站 | 国产精品久久久久乳精品爆 |