Android中补间动画2----Animation的基本使用代码实现复合使用
来源:互联网 发布:付款时淘宝系统异常 编辑:程序博客网 时间:2024/06/05 14:54
效果图:
Main2Activity
package com.zhh.android;import android.animation.AnimatorSet;import android.app.Activity;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.RotateAnimation;import android.widget.Button;import android.widget.ImageView;import android.widget.Toast;/** * 复合动画 */public class Main2Activity extends Activity { private Button btnScale; private ImageView ivLauncher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); 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) { setRecombination(); } }); ivLauncher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Main2Activity.this,Main3Activity.class)); } }); } /** * 创建复合动画 */ private void setRecombination(){// 效果:透明度从透明到不透明,持续时间2s,接着旋转360动画,持续1s// 1创建透明动画,并设置 AlphaAnimation alphaAnimation = new AlphaAnimation(0f,1f); alphaAnimation.setDuration(2000);// 2创建旋转动画,并设置 RotateAnimation rotateAnimation = new RotateAnimation(0,360, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f); rotateAnimation.setDuration(1000);// 延时两秒 rotateAnimation.setStartOffset(2000);// 3创建复合动画对象 AnimationSet animationSet = new AnimationSet(true);// 4添加两个动画 animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(rotateAnimation);// 5启动复合动画对象 ivLauncher.startAnimation(animationSet); }}activity_main2.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中补间动画2----Animation的基本使用代码实现复合使用
- Android中补间动画1----Animation的基本使用代码实现(平移,缩放,渐变,旋转)
- Android--Animation动画的基本使用与介绍
- android 视图动画的使用,Animation重写 实现旋转效果
- Android Animation Tween动画效果的使用
- Android Animation Tween动画效果的使用
- Android动画Animation的使用详解
- Android动画Animation的使用详解
- Android常用动画Animation的使用
- android Animation动画的xml使用
- Android之动画Animation的使用
- android Animation动画的xml使用
- Android: Property Animation 属性动画的使用
- Android之 Animation动画的使用
- android Animation动画的xml使用
- Android中补间动画4----Animation的插值器Interpolator的使用
- 使用Animation实现摄像机动画
- Android下Animation动画的使用 及 Volley加载图片动画实现
- 菜鸟译文(三)——JDK6和JDK7中substring()方法的对比
- Python的C拓展简介
- HDU2001
- Android中实现连续点击功能
- sass函数功能
- Android中补间动画2----Animation的基本使用代码实现复合使用
- NodeJs 读取服务器文件
- Git
- InitializingBean的作用
- centos6.4下MySQL数据库的安装和配置(超详细,超实用!)
- 用SMO算法求解支持向量机(SVM)pythony源代码(三)
- AcDbHatch::setPatternAngle
- GB28181知识培训ppt
- idea 项目启动报错解决,java.lang.OutOfMemoryError:Java heap space