测试drawable animation
public class DAActivity extends Activity implements OnClickListener {
private ImageView iv_da_mm;
private Button btn_da_start;
private Button btn_da_stop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animation_da);
iv_da_mm = (ImageView) findViewById(R.id.iv_da_mm);
btn_da_start = (Button) findViewById(R.id.btn_da_start);
btn_da_stop = (Button) findViewById(R.id.btn_da_stop);
btn_da_start.setOnClickListener(this);
btn_da_stop.setOnClickListener(this);
}
private AnimationDrawable animationDrawable;
@Override
public void onClick(View v) {
if (v == btn_da_start) {
if(animationDrawable==null) {
//得到背景动画图片对象
animationDrawable = (AnimationDrawable) iv_da_mm.getBackground();
//启动
animationDrawable.start();
}
} else if (v == btn_da_stop) {
if(animationDrawable!=null) {
animationDrawable.stop();
animationDrawable = null;
}
}
}
}

drawable_animation_test.xml
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@drawable/nv1"
android:duration="500"/>
<item
android:drawable="@drawable/nv2"
android:duration="500"/>
<item
android:drawable="@drawable/nv3"
android:duration="500"/>
<item
android:drawable="@drawable/nv4"
android:duration="500">
</item>
</animation-list>
activity_animation_da.xml
<?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/iv_da_mm"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="160dp"
android:background="@drawable/drawable_animation_test"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<Button
android:id="@+id/btn_da_start"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="启动动画" />
<Button
android:id="@+id/btn_da_stop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="结束动画" />
</LinearLayout>
</RelativeLayout>
测试drawable animation的更多相关文章
- 动画的使用—Drawable Animation
Drawable Animation可以称为帧动画,因为它是通过每次播放一帧Drawable资源实现的. Drawable Animation算不上真正意义上的动画,因为它的内部实现是通过定时发送消息 ...
- Android动画Drawable Animation
Drawable Animation是逐帧动画,那么使用它之前必须先定义好各个帧.我们可以通过代码定义,也可以使用xml文件定义,一般使用后者.如下: <?xml version="1 ...
- Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation
程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...
- Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)
1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...
- Android animation学习笔记之view/drawable animation
前一章中总结了android animation中property animation的知识和用法,这一章总结View animation和Drawable animation的有关知识: View ...
- 动画的使用—Drawable Animation
Drawable Animation可以称为帧动画,因为它是通过每次播放一帧Drawable资源实现的. Drawable Animation算不上真正意义上的动画,因为它的内部实现是通过定时发送消息 ...
- 【Android界面实现】Drawable Animation 使用介绍
转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 (眼下仅仅能用在View对象上的动画效果的实现有两种,一种就是上一篇的View Animat ...
- Android动画View Animation与Drawable Animation
Animations 一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等, ...
- drawable animation
drawable 动画,帧动画: 1 定义动画xml文件 <?xml version="1.0" encoding="utf-8"?> <an ...
随机推荐
- dogpile搜索引擎
有发现了一个新的搜索引擎——dogpile,结果还不错.据说是综合了多个搜索引擎的结果,展现了最终的搜索结果. 从百科上介绍说,这是一个[元搜索引擎].不懂,继续百科之,如下: 搜索引擎分为全文搜索引 ...
- 亿图图示专家V7破解版
“破解文件”目录下的三个文件拷贝出来复制到安装目录下即可: 下载链接地址: http://cloud.suning.com/cloud-web/share/link.htm?sk=718100ef90 ...
- Win7如何自定义鼠标右键菜单 添加在此处打开CMD窗口
将下面文件保存为"右键添加在此处打开CMD窗口.reg"双击导入运行即可 Windows Registry Editor Version 5.00 [HKEY_CLASSES_RO ...
- vue key 的另外一个用法 过度
key也可以用于强制替换元素/组件而不是重复使用它.当你遇到如下场景时它可能会很有用: 完整地触发组件的生命周期钩子 触发过渡 例如: <transition> <span :key ...
- DIV旋转的測试代码
<html> <head> <style type="text/css"> .rat0 { -webkit-transform: rotate( ...
- MFC中几个函数的使用
1.GetDlgItem() CWnd* GetDlgItem ( int nID ) const;这个就足够了(在MFC中经常这么用),如果你是在win32API下面写的话,那么一般创建一个窗口 ...
- 朴素贝叶斯分类算法-----java
1.贝叶斯分类的基础--贝叶斯定理 已知某条件概率.怎样得到两个事件交换后的概率,也就是在已知P(A|B)的情况下怎样求得P(B|A). 这里先解释什么是条件概率: 表示事件B已经发生的前提下,事件A ...
- hdu1081 最大子矩阵
最大子矩阵自然直在最大连续子序列的升级版 只是其原理都是用到了动态规划思想 仅仅是矩阵用到了枚举 +合并 把非常多列看成是一列的和 #include<stdio.h> ...
- Android Calendar的学习与运用
[java]mport java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; ...
- 【转】基于eclipse进行ndk开发的环境配置
前述虽然我们在其他的博文中(如https://blog.csdn.net/ericbar/article/details/76602720),早就用到了ndk,但如果想在Android设备运行包含这些 ...