7 animation 旋转、透明、缩小
来源:互联网 发布:yii2 开源 cms 编辑:程序博客网 时间:2024/05/21 02:42
-------------------------------main.java-------------------------------
package com.example.jio;
import java.util.Timer;
import java.util.TimerTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends ActionBarActivity {
//加载第一份动画资源
Animation animation ;
//加载第2份动画资源
Animation reverse;
ImageView imageView;
final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0x123) {
imageView.startAnimation(reverse);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView) findViewById(R.id.imageView1);
animation = AnimationUtils.loadAnimation(this, R.anim.anim);
//设置动画结束后保留结束状态
animation.setFillAfter(true);
reverse = AnimationUtils.loadAnimation(this, R.anim.reverse);
//设置动画结束后保留结束状态
reverse.setFillAfter(true);
}
public void playOnclick(View view) {
imageView.startAnimation(animation);
//设置3.5秒后启动第二个动画
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
handler.sendEmptyMessage(0x123);
}
}, 3500);
}
}
。。。。。。。。。。。。main.xml。。。。。。。。。。。。。。。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
<Button
android:id="@+id/button1"
android:onClick="playOnclick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="播放动画" />
</LinearLayout>
。。。。。。。。。。。。。/res/anim/anim.xml。。。。。。。。。。。。。。
<?xml version="1.0" encoding="utf-8"?>
<set
android:interpolator="@android:anim/linear_interpolator"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 定义缩放变换 -->
<scale
android:fromXScale="1.0"
android:toXScale="0.01"
android:fromYScale="1.0"
android:toYScale="0.01"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="true"
android:duration="3000"
/>
<!-- 定义透明度的变换 -->
<alpha
android:fromAlpha="1"
android:toAlpha="0.05"
android:duration="3000"
/>
<!-- 定义旋转变换 -->
<rotate
android:fromDegrees="0"
android:toDegrees="1800"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000"
/>
</set>
。。。。。。。。。。。。/res/anim/reverse.xml。。。。。。。。。。。。。。。
<?xml version="1.0" encoding="utf-8"?>
<set
android:interpolator="@android:anim/linear_interpolator"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 定义缩放变换 -->
<scale
android:fromXScale="0.01"
android:toXScale="1"
android:fromYScale="0.01"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="true"
android:duration="3000"
/>
<!-- 定义透明度的变换 -->
<alpha
android:fromAlpha="0.05"
android:toAlpha="1"
android:duration="3000"
/>
<!-- 定义旋转变换 -->
<rotate
android:fromDegrees="1800"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000"
/>
</set>
- 7 animation 旋转、透明、缩小
- cocos2d各种动作的使用(变色、跳动、旋转、闪烁、悬挂、放大缩小、渐变、animation)(三)
- cocos2d各种动作的使用(变色、跳动、旋转、闪烁、悬挂、放大缩小、渐变、animation)
- ---Transform---放大缩小旋转
- Animation 动画透明转换
- Animation旋转360度
- Animation旋转的动画
- android 旋转,放大,缩小图片
- picturebox放大、缩小、旋转、拖拽
- silverlight图片旋转、放大、缩小
- 放大、缩小、旋转、开始动画
- 控件移动,放大,缩小,旋转
- unity触摸放大缩小旋转
- Android animation - 文字旋转示例
- 旋转动画 uiview animation rotate
- 旋转动画 uiview animation rotate
- 旋转菜单 采用Animation方式
- GDI透明旋转平移图片
- 攻略强制换行与强制不换行
- 实例:实现动态网页的静态缓存
- 父类与子类的构造顺序
- LeetCode[Map]: Longest Consecutive Sequence
- iOS游戏安全之IPA破解原理及防御
- 7 animation 旋转、透明、缩小
- pat 1056
- 新建Oracle用户和表空间
- 雷军豹变
- swift UI专项训练33 Switch开关
- eclipse的字体颜色修改
- OLAP的学习与实例搭建
- Html5 animation详解
- JavaScript 之arguments、caller 和 callee