欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 中 Tweened animation的實(shí)例詳解

 更新時(shí)間:2017年09月25日 11:25:08   作者:zhangqijie001  
這篇文章主要介紹了Android 中 Tweened animation的實(shí)例詳解的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家理解掌握這部分內(nèi)容,需要的朋友可以參考下

Android 中 Tweened animation的實(shí)例詳解

Tweened animation有四種類(lèi)型,下面主要介紹Scale類(lèi)型。

運(yùn)行效果如下:

Android SDK提供了2種方法:直接從XML資源中讀取Animation,使用Animation子類(lèi)的構(gòu)造函數(shù)來(lái)初始化Animation對(duì)象,第二種方法在看了Android SDK中各個(gè)類(lèi)的說(shuō)明就知道如何使用了,下面簡(jiǎn)要說(shuō)明從XML資源中讀取Animation。XML資源中的動(dòng)畫(huà)文件animation.xml內(nèi)容為:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
  <scale 
    android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
    android:fromXScale="0.0" 
    android:toXScale="1.4" 
    android:fromYScale="0.0" 
    android:toYScale="1.4" 
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:fillAfter="false" 
    android:startOffset="3000" 
    android:duration="3000" 
    android:repeatCount="4"/> 
</set> 

主文件ScaleAnimation.java內(nèi)容為:

package com.android.animation; 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.ImageView; 
public class TestAnimation extends Activity { 
  /** Called when the activity is first created. */ 
  @Override 
  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    ImageView imageView = (ImageView) findViewById(R.id.imageview); 
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.animation); 
    imageView.startAnimation(animation); 
  } 
} 

程序很容易看懂,主要為了說(shuō)明伸縮動(dòng)畫(huà)效果而沒(méi)有增加復(fù)雜性。值得說(shuō)明的是,本人在測(cè)試階段,錯(cuò)誤的認(rèn)為不需要布局文件,把行setContentView(R.layout.main);去掉,導(dǎo)致程序運(yùn)行一直出錯(cuò)。其實(shí)動(dòng)畫(huà)也需要首先把布局文件加載到Activity里面,然后對(duì)布局里面的控件增加動(dòng)畫(huà)。

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論