【Android】Android图形之Animate
来源:互联网 发布:计算复杂性 口头算法 编辑:程序博客网 时间:2024/06/11 05:23
Frame Animate
语法:
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot=["true" | "false"] > <item android:drawable="@[package:]drawable/drawable_resource_name" android:duration="integer" /></animation-list>
package com.msi.manning.chapter9.xmlanimate;import java.util.Timer;import java.util.TimerTask;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.widget.ImageView;public class XMLAnimate extends Activity {@Overridepublic void onCreate(Bundle icicle) {super.onCreate(icicle);setContentView(R.layout.main);ImageView img = (ImageView) findViewById(R.id.simple_anim);img.setBackgroundResource(R.anim.simple_animation);MyAnimationRoutine mar = new MyAnimationRoutine();MyAnimationRoutine2 mar2 = new MyAnimationRoutine2();Timer t = new Timer(false);t.schedule(mar, 100);Timer t2 = new Timer(false);t2.schedule(mar2, 5000);}class MyAnimationRoutine extends TimerTask {@Overridepublic void run() {ImageView img = (ImageView) findViewById(R.id.simple_anim);AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();frameAnimation.start();}}class MyAnimationRoutine2 extends TimerTask {@Overridepublic void run() {ImageView img = (ImageView) findViewById(R.id.simple_anim);AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();frameAnimation.stop();}}}
main.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout 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/simple_anim" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:gravity="center" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello World, XMLAnimation" /></LinearLayout>
simple_animation.xml:
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" id="selected" android:oneshot="false" > <item android:drawable="@drawable/ball1" android:duration="50"/> <item android:drawable="@drawable/ball2" android:duration="50"/> <item android:drawable="@drawable/ball3" android:duration="50"/> <item android:drawable="@drawable/ball4" android:duration="50"/> <item android:drawable="@drawable/ball5" android:duration="50"/> <item android:drawable="@drawable/ball6" android:duration="50"/></animation-list>
- 【Android】Android图形之Animate
- Android 图形系统之图形缓冲区分配
- android编程之图形绘制
- Android图形系统之libui
- Android图形系统之libui
- android之各种图形绘制
- Android Material Design 之 图形
- Android 图形系统之gralloc
- 【Android】Android图形之shape使用
- 【Android】Android图形之shape使用
- Android:图形
- android图形
- Android开发之Shap自定义图形
- Android开发之Shap自定义图形
- Android开发之Shap自定义图形
- Android 图形用户界面 之 绘图(一)
- 转战Android之NDK(图形绘制)
- Android游戏编程之基本图形编程
- block 和 inline 的区别是什么
- OOAD之设计模式-行为模式
- [疯狂Java讲义精粹] 第九章|Annotation(注释)
- sql教程
- How do I trim leading/trailing whitespace in a standard way?
- 【Android】Android图形之Animate
- hdu 1728 逃离迷宫 BFS
- hash_map 与 hash_set 详解
- 从30岁至35岁:为你的生命多积累一些厚度
- jQuery属性过滤选择器
- Bad Hair Day
- 黑马程序员 java中的位运算总结
- 黑马程序员_java银行业务调度系统的分析、设计、实现
- 路