iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android 四种动画效果的调用实现代码
  • 591
分享到

Android 四种动画效果的调用实现代码

调用动画Android 2022-06-06 10:06:24 591人浏览 安东尼
摘要

(1) main.xml 代码如下:(声明四个按钮控件) XML代码: 代码如下: <?xml version="1.0" encoding="utf-8"?>

(1) main.xml 代码如下:(声明四个按钮控件)
XML代码:
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
Android:id="@+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="Http://schemas.android.com/apk/res/android"
>
<TextView
android: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>
<Button
android: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>
<Button
android: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>
<Button
android: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>
<Button
android: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 {

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;
@Override
public 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 stub
switch (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仿微信雷达辐射搜索好友(逻辑清晰实现简单)Android 吸入动画效果实现分解Android动画之3D翻转效果实现函数分析Android图片翻转动画简易实现代码Android 3D旋转动画效果实现分解Android启动画面的实现方法Android动画之雷达扫描效果


--结束END--

本文标题: Android 四种动画效果的调用实现代码

本文链接: https://www.lsjlt.com/news/27943.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作