Android Animation--->TweemAnimation运用

-------------------------

-----------旋转+反转

//reverse +rotate
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="
http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<rotate
android:repeatCount="10"
android:repeatMode="reverse"
android:duration="8000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
</rotate>

</set>

-------------颜色亮到透明 反复
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="
http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<alpha
android:duration="3000"
android:fromAlpha="0.2"
android:repeatCount="10"
android:repeatMode="reverse"
android:toAlpha="1.0" />

</set>

--------------------------------.java

package gongzibai.co.cc;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class Animation1Activity extends
Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView mImageView = (ImageView) findViewById(R.id.imageView1);
mImageView
.setImageResource(R.drawable.icon);

findViewById(R.id.button15)
.setOnClickListener(
new OnClickListener() {

@Override
public void onClick(
View v) {
// TODO Auto-generated method stub
final Animation animation2 = AnimationUtils
.loadAnimation(
Animation1Activity.this,
R.anim.setanimation1);

//mimageviewadd animation

mImageView
.startAnimation(animation2);

}
});
findViewById(R.id.button2)
.setOnClickListener(
new OnClickListener() {

@Override
public void onClick(
View v) {
// TODO Auto-generated method stub

final Animation animation1 = AnimationUtils
.loadAnimation(
Animation1Activity.this,
R.anim.setanimation);
mImageView
.startAnimation(animation1);

}
});

findViewById(R.id.button3)
.setOnClickListener(
new OnClickListener() {

@Override
public void onClick(
View v) {
// TODO Auto-generated method stub

final Animation animation2 = AnimationUtils
.loadAnimation(
Animation1Activity.this,
R.anim.setanimation2);
mImageView
.startAnimation(animation2);

}
});

findViewById(R.id.button4)
.setOnClickListener(
new OnClickListener() {

@Override
public void onClick(
View v) {
new AnimationUtils();
// TODO Auto-generated method stub
final Animation animation3 = AnimationUtils
.loadAnimation(
Animation1Activity.this,
R.anim.alpha_animation);
mImageView
.startAnimation(animation3);

}
});
}
}

-----------------------

-----


--------------FRAMEANIMATION自动运行

// auto run--->hasfocus--->onwindowfocusChanged...
@Override
public void onWindowFocusChanged(
boolean hasFocus) {
// TODO Auto-generated method stub
if (hasFocus) {
fireanimation.start();

} else {
fireanimation.stop();
}
super.onWindowFocusChanged(hasFocus);
}
------------
-------------.java
mImageView
.setBackgroundResource

(R.anim.fireanim);

fireanimation = (AnimationDrawable) mImageView
.getBackground();
---------<?xml version="1.0" encoding="UTF-8"?>

// add <animation-list> </animation-list>

//add <item>
<animation-list

xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" >

<item
android:drawable="@drawable/fire01"
android:duration="100"/>

<item
android:drawable="@drawable/fire02"
android:duration="600"/>
</animation-list>

-----------XML里的IMAGEVIEW不能加载图片,否则,FRAMEANIMATION无效果...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值