Android 四种动画效果的调用
来源:互联网 发布:协议号和端口号的区别 编辑:程序博客网 时间:2024/05/16 07:07
在这里, 我将每种动画分别应用于四个按钮为例:
java代码:
效果图:
(1) main.xml 代码如下:(声明四个按钮控件)
XML代码:
<?xml version="1.0" encoding="utf-8"?><AbsoluteLayoutandroid:id="@+id/widget32"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"><TextViewandroid:id="@+id/widget29"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@string/hello"android:layout_x="0px"android:layout_y="0px"></TextView><Buttonandroid:id="@+id/button_Alpha"android:layout_width="150px"android:layout_height="150px"android:text="Alpha动画"android:textSize="50px"android:layout_x="0px" android:layout_y="30px"></Button><Buttonandroid:id="@+id/button_Scale"android:layout_width="150px"android:layout_height="150px"android:text="Scale动画"android:textSize="50px"android:layout_x="0px" android:layout_y="180px"></Button><Buttonandroid:layout_width="150px"android:layout_height="150px"android:text="Translate动画"android:layout_x="161px" android:layout_y="30px" android:textSize="30px" android:id="@+id/button_Translate"></Button><Buttonandroid:id="@+id/button_Rotate"android:layout_width="150px"android:layout_height="150px"android:text="Rotate动画"android:layout_y="180px" android:layout_x="161px" android:textSize="44px"></Button></AbsoluteLayout>
java代码:
import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.Button;public class myActionAnimation extends Activity implements OnClickListener {/** Called when the activity is first created. */private Button button_alpha;private Button button_scale;private Button button_translate;private Button button_rotate;private Animation myAnimation_Alpha;private Animation myAnimation_Scale;private Animation myAnimation_Translate;private Animation myAnimation_Rotate;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);button_alpha = (Button) findViewById(R.id.button_Alpha);button_alpha.setOnClickListener(this);button_scale = (Button) findViewById(R.id.button_Scale);button_scale.setOnClickListener(this);button_translate = (Button) findViewById(R.id.button_Translate);button_translate.setOnClickListener(this);button_rotate = (Button) findViewById(R.id.button_Rotate);button_rotate.setOnClickListener(this);}public void onClick(View button) {// TODO Auto-generated method stubswitch (button.getId()) {case R.id.button_Alpha: {myAnimation_Alpha = AnimationUtils.loadAnimation(this,R.layout.my_alpha_action);button_alpha.startAnimation(myAnimation_Alpha);}break;case R.id.button_Scale: {myAnimation_Scale= AnimationUtils.loadAnimation(this,R.layout.my_scale_action);button_scale.startAnimation(myAnimation_Scale);}break;case R.id.button_Translate: {myAnimation_Translate= AnimationUtils.loadAnimation(this,R.layout.my_translate_action);button_translate.startAnimation(myAnimation_Translate);}break;case R.id.button_Rotate: {myAnimation_Rotate= AnimationUtils.loadAnimation(this,R.layout.my_rotate_action);button_rotate.startAnimation(myAnimation_Rotate);}break;default:break;}}}
效果图:
- Android 四种动画效果的调用
- Android 四种基本的动画效果
- UIView 动画效果的四种调用方式
- UIView 动画效果的四种调用方式
- Android 动画效果(二):四种基础动画的 **动态设置、动画监听、组合动画
- android的四种动画效果详解及示例
- android Animations 动画效果(四)
- 调用键盘的动画效果
- JQuery制作四种简易的动画效果
- Android 动画效果(一): 四种动画基础(Alpha、Translate、Rotate、Scale)
- Android的animation的四种动画
- Android四种动画
- Android四种动画
- Android Tween动画的四种方式
- android TWEEN的四种动画
- Android 动画的四种布局
- Android的四种基础动画
- android学习-动画(基本的四种动画)
- lucene、lucene.NET详细使用与优化详解
- hhhhhhhhhhhhhhh
- android binder机制及其源码解析 之 第一节 概述
- PPTP问题解决——只允许一个用户登陆
- 深入剖析TCP协议的send与recv
- Android 四种动画效果的调用
- ibatis操作clob字段(oracle9i,ibatis2.3)
- socket编程
- Joda Time--jdk日期时间库的完美替代
- Cairngorm组成及运行原理
- android:绘图
- SIMD&VLIW
- 一台机器同时运行两个或多个tomcat
- dll与lib文件的区别和联系【zz】