android-Animation 四种基本动画
来源:互联网 发布:辐射44g内存怎么优化 编辑:程序博客网 时间:2024/06/09 06:01
旋转,淡化,放大缩小,。。四种动画
下载这个图片改为压缩文件就可以看到源码。右键这个显示不出来的图片 复制图片地址 用工具下载之后,把后缀改为rar就是源码项目。
package zhang.Animation;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.RotateAnimation;import android.view.animation.ScaleAnimation;import android.view.animation.TranslateAnimation;import android.widget.Button;import android.widget.ImageView;public class Animation_ extends Activity {private Button rotate;private Button scale;private Button alpha;private Button translate;private ImageView imageView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); rotate=(Button)findViewById(R.id.rotate); scale=(Button)findViewById(R.id.scale); alpha=(Button)findViewById(R.id.alpha); translate=(Button)findViewById(R.id.translate); imageView=(ImageView)findViewById(R.id.img); rotate.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubAnimationSet animationSet = new AnimationSet(true);RotateAnimation rotateAnimation = new RotateAnimation(0,360,Animation.RELATIVE_TO_PARENT,1f,Animation.RELATIVE_TO_PARENT,0f);rotateAnimation.setDuration(1000);animationSet.addAnimation(rotateAnimation);imageView.startAnimation(animationSet);}}); alpha.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubAnimationSet animationSet = new AnimationSet(true);AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);alphaAnimation.setDuration(1000);animationSet.addAnimation(alphaAnimation);imageView.startAnimation(animationSet);}}); scale.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubAnimationSet animationSet = new AnimationSet(true);ScaleAnimation scaleAnimation =new ScaleAnimation(1,0.1f,1,0.1f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);animationSet.addAnimation(scaleAnimation);animationSet.setDuration(2000);imageView.startAnimation(animationSet);}}); translate.setOnClickListener(new TranslateListener()); } class TranslateListener implements OnClickListener{ public void onClick(View arg0) {// TODO Auto-generated method stubAnimationSet animationSet = new AnimationSet(true);TranslateAnimation translateAnimation=new TranslateAnimation(Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,10f,Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,1.0f);translateAnimation.setDuration(1000);animationSet.addAnimation(translateAnimation);imageView.startAnimation(animationSet);} }}
<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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/img" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/icon"android:layout_centerInParent="true"android:layout_marginTop="100dip" /><Button android:text="Rotate" android:id="@+id/rotate" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/scale"></Button><Button android:text="Scale" android:id="@+id/scale" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/alpha" ></Button><Button android:text="Alpha" android:id="@+id/alpha" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/translate"></Button><Button android:text="Translate" android:id="@+id/translate" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"></Button></RelativeLayout>
- android-Animation 四种基本动画
- Android的animation的四种动画
- android Tween Animation四种动画
- android Tween Animation四种动画
- Animation四种动画详解
- Android属性动画---Property Animation(四)
- Android动画之Property Animation(四)
- Android-帧动画Animation基本实现
- Android基本的动画& animation工具类
- Android 四种基本的动画效果
- Animation动画详解(四)——ValueAnimator基本使用
- Animation动画详解(四)——ValueAnimator基本使用
- android学习-动画(基本的四种动画)
- Android属性动画-Property Animation(四) 组合动画
- Android属性动画-Property Animation(四) 组合动画
- Animation五种基本动画解析
- 传统动画Animation的四种基础动画的使用
- 传统动画Animation的四种基础动画的使用
- Linux调试中使用的proc和sys中的接口
- 连接池未关闭问题的发现与解决
- 最新pcre库在windows平台编译完整过程
- 形态学函数cvErode、cvDilate使用说明
- MFC学习笔记之七————工具栏编程与状态栏编程
- android-Animation 四种基本动画
- 用memcache.php监测memcache的状况
- [扩展/新建swap]将文件或分区加载为swap
- java笔记总结_07_多线程
- ubuntu nfs 挂载总结
- CL 编译器选项总结
- Dinic最大流模版
- Oracle Join 用法
- 我奋斗了18年才和你坐在一起喝咖啡