Android动画之RotateAnimation
来源:互联网 发布:mac电脑卸载软件 编辑:程序博客网 时间:2024/05/22 14:22
1.旋转动画RotateAnimation
rotate_animation.xml
<?xml version="1.0" encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator"android:duration="2000"android:fillAfter="true"> <rotate android:fromDegrees="0" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%"/></set>
android:fromDegrees——开始的角度
android:toDegrees——结束的角度
android:pivotX——旋转轴点的x轴的坐标
android:pivotY——旋转轴点的y轴的坐标
android:interpolator=”@android:anim/accelerate_decelerate_interpolator”即为加速减速插值器
2.在代码中加入动画效果
package com.zhoujian.animation;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.LinearInterpolator;import android.view.animation.RotateAnimation;import android.widget.Button;import android.widget.ImageView;import butterknife.ButterKnife;import butterknife.InjectView;public class MainActivity extends Activity { @InjectView(R.id.start) Button mStart; @InjectView(R.id.img) ImageView mImg; @InjectView(R.id.start_one) Button mStartOne; private Animation mAnimation; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); clickEvent(); } private void clickEvent() { mStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //mAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha_animation); //mImg.startAnimation(mAnimation); //创建动画 AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1); //动画持续时间 alphaAnimation.setDuration(5000); //动画停留在结束的位置 alphaAnimation.setFillAfter(true); //开启动画 mImg.startAnimation(alphaAnimation); } }); mStartOne.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //利用资源文件加载动画 //mAnimation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate_animation); //mImg.startAnimation(mAnimation); //在代码中使用动画 RotateAnimation animation = new RotateAnimation(0,360,RotateAnimation.RELATIVE_TO_SELF,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f); //不停顿 animation.setInterpolator(new LinearInterpolator()); //重复次数 animation.setRepeatCount(0); animation.setFillAfter(true); animation.setDuration(2000); //开启动画 mImg.startAnimation(animation); } }); }}
3.运行效果截图
0 0
- Android动画之RotateAnimation
- Android Tween动画之RotateAnimation
- Android 常用动画之RotateAnimation
- Android动画之RotateAnimation使用
- Android 动画 Tweened Animation 之 RotateAnimation
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android动画之RotateAnimation的基本用法
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用实例
- Android动画-RotateAnimation
- 53. Maximum Subarray
- 统一修改填报属性“模式”,而不修改其它属性
- 基于随机游走的社团划分算法label progation 的python实现
- 请不要滥用SharedPreference
- hashMap、hashTable
- Android动画之RotateAnimation
- ES2015数组扩展 - Array.from()
- Scala:AnyRef和AnyVal
- UniWebView ,unity项目显示web,不支持pc
- Spring MVC拦截器
- Shell:函数、输入输出重定向、文件包含
- Android使用SQLITE3 WAL模式
- html、css、js文件加载顺序及执行情况
- React Native之ViewPagerAndroid 组件