Animations
来源:互联网 发布:贵州广电网络微博 编辑:程序博客网 时间:2024/05/18 23:14
importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;importandroid.view.animation.AnimationSet;importandroid.view.animation.RotateAnimation;importandroid.view.animation.ScaleAnimation;import android.view.animation.TranslateAnimation;importandroid.widget.Button;importandroid.widget.ImageView;public class Animation1Activity extends Activity { private Button rotateButton = null; private Button scaleButton = null; private Button alphaButton = null; private Button translateButton = null; private ImageView image = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); rotateButton = (Button)findViewById(R.id.rotateButton); scaleButton = (Button)findViewById(R.id.scaleButton); alphaButton = (Button)findViewById(R.id.alphaButton); translateButton = (Button)findViewById(R.id.translateButton); image = (ImageView)findViewById(R.id.image); rotateButton.setOnClickListener(newRotateButtonListener()); scaleButton.setOnClickListener(newScaleButtonListener()); alphaButton.setOnClickListener(newAlphaButtonListener()); translateButton.setOnClickListener( new TranslateButtonListener()); } class AlphaButtonListener implementsOnClickListener{ public void onClick(View v) { //创建一个AnimationSet对象,参数为Boolean型, //true表示使用Animation的interpolator,false则是使用自己的 AnimationSet animationSet = new AnimationSet(true); //创建一个AlphaAnimation对象,参数从完全的透明度,到完全的不透明 AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0); //设置动画执行的时间 alphaAnimation.setDuration(500); //将alphaAnimation对象添加到AnimationSet当中 animationSet.addAnimation(alphaAnimation); //使用ImageView的startAnimation方法执行动画 image.startAnimation(animationSet); } } class RotateButtonListener implementsOnClickListener{ public void onClick(View v) { AnimationSet animationSet = new AnimationSet(true); //参数1:从哪个旋转角度开始 //参数2:转到什么角度 //后4个参数用于设置围绕着旋转的圆的圆心在哪里 //参数3:确定x轴坐标的类型,有ABSOLUT绝对坐标、RELATIVE_TO_SELF相对于自身坐标、RELATIVE_TO_PARENT相对于父控件的坐标 //参数4:x轴的值,0.5f表明是以自身这个控件的一半长度为x轴 //参数5:确定y轴坐标的类型 //参数6:y轴的值,0.5f表明是以自身这个控件的一半长度为x轴 RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f); rotateAnimation.setDuration(1000); animationSet.addAnimation(rotateAnimation); image.startAnimation(animationSet); } } class ScaleButtonListener implementsOnClickListener{ public void onClick(View v) { AnimationSet animationSet = new AnimationSet(true); //参数1:x轴的初始值 //参数2:x轴收缩后的值 //参数3:y轴的初始值 //参数4:y轴收缩后的值 //参数5:确定x轴坐标的类型 //参数6:x轴的值,0.5f表明是以自身这个控件的一半长度为x轴 //参数7:确定y轴坐标的类型 //参数8:y轴的值,0.5f表明是以自身这个控件的一半长度为x轴 ScaleAnimation scaleAnimation = new ScaleAnimation( 0, 0.1f,0,0.1f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f); scaleAnimation.setDuration(1000); animationSet.addAnimation(scaleAnimation); image.startAnimation(animationSet); } } class TranslateButtonListener implementsOnClickListener{ public void onClick(View v) { AnimationSet animationSet = new AnimationSet(true); //参数1~2:x轴的开始位置 //参数3~4:y轴的开始位置 //参数5~6:x轴的结束位置 //参数7~8:x轴的结束位置 TranslateAnimation translateAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF,0f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0f, Animation.RELATIVE_TO_SELF,0.5f); translateAnimation.setDuration(1000); animationSet.addAnimation(translateAnimation); image.startAnimation(animationSet); } }}
阅读全文
0 0
- Animations
- Animations
- Animations
- Animations
- Animations
- lwuit Animations
- Android Animations
- uiview animations
- CSS Animations
- UIImageView Animations
- Animations功能
- listview-animations
- Android--Animations
- Android---Animations
- android Animations
- Android Animations
- Android Animations
- Web Animations
- windos系统python3.5如何安装模块
- INTEL Processor Trace for vulnerability discovery
- POJ-2387 Til the Cows Come Home
- js使用 soapclient.js 访问webservice遇到问题" field SOAPAction is not allowed by Access-Control"
- Android中的IPC方式
- Animations
- poj 1751 注意一下他的输出技巧。
- map
- 编辑距离问题
- vue.js移动端app实战1:初始配置
- 2017/8/10训练日记
- 梯度下降(Gradient Descent)
- 用TCP/TP进行网际互连(7) ———— 支持多协议多服务的服务器设计和实现
- mybatis框架中动态sql的应用