测试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 ...
随机推荐
- 【spring cloud】注解@SpringCloudApplication和@SpringBootApplication的区别
@SpringCloudApplication和@SpringBootApplication的区别
- 队列容易queue
/*先进先出*/#include<iostream>#include<queue> //使用队列必须包含头文件using namespace std;int main(){ q ...
- 使用 ODP.NET 访问 Oracle(.net如何访问Oracle)详解【转】
http://www.cnblogs.com/qinpengming/archive/2013/06/08/3127346.html 1,什么是ODF .NE,?就是Oracle 为 .NET (OD ...
- Geographical distance
Introduction Calculating the distance between geographical coordinates is based on some level of abs ...
- linux中find的用法
找所在目录的文件用 find -name “file*” -print #注意不要用加文件路径,查找文件也好用双双引号括住: 也可以 find ./ -name “file*” -print
- Map接口及其子类
Map接口操作的是一对对象,即二元偶对象,Map接口中的每一个元素都使用"key--value"的形式存储在集合中. SortedMap接口是排序接口,仅仅要是实现了此接口的子类, ...
- springMVC --配置具体与注讲解明
<?xml version="1.0" encoding="UTF-8"? > <beans xmlns="http://www.s ...
- UNP学习笔记(第五章 TCP客户/服务程序实例)
我们将在本章使用前一章中介绍的基本函数编写一个完整的TCP客户/服务器程序实例 这个简单得例子是执行如下步骤的一个回射服务器: TCP回射服务器程序 #include "unp.h" ...
- JS创建表单提交备份
//保存 function saveFT() { var data = { createDate: GetDateStr(0), name: $("#txtName").val() ...
- android 获取手机设备品牌
在有些数据要获取手机设备是什么品牌,特别做一些适配的时候,好了就讲下怎样或者手机是什么品牌: String brand =android.os.Build.BRAND; 就这么简单!