简单记录,关于android animation的简单应用。
2013-05-14 16:17
344 查看
findViewById(R.id.translate).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //左右晃动 or 上下晃动 or 斜着 TranslateAnimation animation = new TranslateAnimation(0, mButton.getWidth() + x, 0, 0); animation.setInterpolator(new CycleInterpolator(2f)); animation.setDuration(10000); // animation.setFillEnabled(true); //停止动画button停在那里。 // animation.setFillAfter(true); // animation.setFillBefore(true); animation.initialize(mButton.getWidth(), mButton.getHeight(), mButton.getWidth(), mButton.getHeight()); mButton.startAnimation(animation); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { animation = new TranslateAnimation(0, mButton .getWidth(), 0, 0); animation.setInterpolator(new CycleInterpolator(2f)); animation.setDuration(10000); mButton.startAnimation(animation); } }); } }); findViewById(R.id.rotate).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //旋转 RotateAnimation animation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(10000); mButton.startAnimation(animation); } }); findViewById(R.id.scale).setOnClickListener(new OnClickListener() { //比例放大 @Override public void onClick(View v) {
//参数 1.开始的x轴方向比例2.结束时的x轴方向比例3.y的开始4.y的结束5.开始时的中心坐标(以自己为标准)6.以自己的水品方向的2倍坐标为中心7.y的8.自己y方向的0.5倍坐标及自己的y方向的中心点。
ScaleAnimation animation = new ScaleAnimation(0, 1f, 0, 1f, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(10000); mButton.startAnimation(animation); } }); findViewById(R.id.alpha).setOnClickListener(new OnClickListener() { //透明度 @Override public void onClick(View v) { AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f); alphaAnimation.setDuration(10000); alphaAnimation.setRepeatCount(-1); alphaAnimation.setRepeatMode(Animation.REVERSE); mButton.startAnimation(alphaAnimation); alphaAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } }); } });
相关文章推荐
- 关于android中AsyncTask和jni技术简单应用--附源码
- 关于Android引路蜂地图应用源码的简单说明
- Android学习记录(三十)-- Android 关于手势Gesture的简单实现和实践中遇到的问题。
- 关于android Service服务的一些简单应用
- Android安装应用和跳转应用简单记录
- Android 关于接口(interface)回调函数的简单应用
- android 关于图片缩放,旋转的简单应用
- 关于 Android 应用编程,简单易懂的解释
- Android框架:Retrofit2之第一集简单应用
- Android基础教程之简单的Button事件响应综合提示控件Toast的应用
- 【Android应用开发】-(20)简单的模拟按键发送消息
- 【Android】关于addTextChangedListener()方法的上机记录
- 关于android的animation的xml定义中的android:interpolator属性的含义
- Android学习之界面篇(一)Android Animation简单介绍
- 暑期实习20之android简单应用开发
- Android应用开发中关于this.context=context的理解
- 关于android的animation的xml定义中的android:interpolator属性的含义 『转』
- 关于android应用获取SHA-1的值
- Android 4.4.2 动态添加JNI库方法记录 (二 app应用层)