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无效果...
更多相关文章
- Android实现加载等待展示
- Android的supportV7中默认按钮的颜色设置
- android Activity加载完成后的监听事件
- 72、android状态栏一体化,状态栏改变颜色
- 关于android示例程序(bitmapfun)——高效加载图片的坑爹地方
- 安卓 WebView加载本地图片时居中显示
- [Android]Menu/Button 英文全大写、Menu改变字体颜色