Android中补间动画3----Animation的监听
来源:互联网 发布:mac地址里ig位 编辑:程序博客网 时间:2024/05/29 16:38
效果图:
Main3Activity
package com.zhh.android;import android.app.Activity;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.animation.Animation;import android.view.animation.LinearInterpolator;import android.view.animation.RotateAnimation;import android.widget.Button;import android.widget.ImageView;/** * 动画监听 */public class Main3Activity extends Activity { private Button btnScale; private ImageView ivLauncher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main3); initView(); myOnclick(); } private void initView() { btnScale = (Button)findViewById(R.id.btnScale); ivLauncher = (ImageView)findViewById(R.id.ivLauncher); } private void myOnclick() {// 按钮点击事件 btnScale.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRotateAnimation(); } });// 图片点击事件 ivLauncher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Main3Activity.this,Main4Activity.class)); } }); } /** * 旋转动画 */ private void setRotateAnimation(){// 效果以图片中心点为中心,从负90度到正90度,持续5s// 1创建动画对象 RotateAnimation rotateAnimation = new RotateAnimation(0,360, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);// 2设置 rotateAnimation.setDuration(5000);// 设置线性变化的插值器(线性变化,加速变化,减速变化,周期循环变化) rotateAnimation.setInterpolator(new LinearInterpolator());// 动画重复Animation.INFINITE=-1表示无限旋转 rotateAnimation.setRepeatCount(Animation.INFINITE);// 3启动动画 ivLauncher.startAnimation(rotateAnimation); rotateAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { Log.e("111","动画开始"); } @Override public void onAnimationEnd(Animation animation) { Log.e("111","动画结束"); } @Override public void onAnimationRepeat(Animation animation) { Log.e("111","动画重复"); } }); }}activity_main3.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.zhh.android.Main2Activity" android:orientation="vertical" > <Button android:id="@+id/btnScale" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="动画的监听事件" android:textSize="30dp" /> <ImageView android:id="@+id/ivLauncher" android:layout_width="wrap_content" android:layout_height="200dp" android:src="@mipmap/cyl" android:layout_gravity="center_horizontal" /></LinearLayout>参考视频:
http://www.gulixueyuan.com/course/112/task/1793/show#
源码下载:
阅读全文
0 0
- Android中补间动画3----Animation的监听
- Android Animation 帧动画监听结束的方法
- 关于Android动画的监听,开始,结束的控制分别有 Animation 动画和 ObjectAnimator 动画
- Android的animation(动画)
- Android的animation动画
- 监听UIView animation的动画过程
- 监听animation动画事件
- Android的Animation动画相继
- Android动画的实现Animation
- android的动画效果Animation
- Android Animation(3)-Android的动画框架
- Android中补间动画4----Animation的插值器Interpolator的使用
- android Animation 对Android动画的理解
- Android当中的动画3—自定义Tween Animation
- Android的animation的四种动画
- Android 的动画 I-基础知识和View Animation&Drawable Animation
- Android动画-Android Animation
- 【Android】【动画】Android 动画 (Animation)
- JavaScript基础(四)jQuery(一)
- vue中 关于$emit的用法
- Webpack devServer中的 proxy 实现跨域
- intellij IDEA配置tomcat
- 趣学算法系列-分治法
- Android中补间动画3----Animation的监听
- 分布式锁那点事
- 30分钟掌握ES6/ES2015核心内容
- Android 姓名的校验
- while(~scanf("%d%d",&a,&b))的含义
- v-model修饰符.lazy详解
- iOS-代码加载storyboard中的ViewController
- ZooKeeper应用举例
- Java基础03 构造器与方法重载