1.设置背景方式
a.在res创建一个anim文件夹,该文件夹下创建animation_list.xml文件
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" >
<item
android:drawable="@drawable/c1"
android:duration="200"/>
<item
android:drawable="@drawable/c2"
android:duration="200"/>
<item
android:drawable="@drawable/c3"
android:duration="200"/>
<item
android:drawable="@drawable/c4"
android:duration="200"/>
<item
android:drawable="@drawable/c5"
android:duration="200"/>
<item
android:drawable="@drawable/c6"
android:duration="200"/>
</animation-list>
b. layout文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingTop="50dp" >
</ImageView>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Run"
android:onClick="run">
</Button>
</LinearLayout>
c.java代码
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.contextmenu);
imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setBackgroundResource(R.anim.animation_list);
draw = (AnimationDrawable) imageView.getBackground();
// draw = (AnimationDrawable) imageView.getDrawable();
}
public void run(View v) {
if (draw.isRunning()) {
draw.stop();
} else {
draw.stop();
draw.start();
}
}
2.设置SRC方式
a.在res创建一个anim文件夹,该文件夹下创建animation_list.xml文件
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" >
<item
android:drawable="@drawable/c1"
android:duration="200"/>
<item
android:drawable="@drawable/c2"
android:duration="200"/>
<item
android:drawable="@drawable/c3"
android:duration="200"/>
<item
android:drawable="@drawable/c4"
android:duration="200"/>
<item
android:drawable="@drawable/c5"
android:duration="200"/>
<item
android:drawable="@drawable/c6"
android:duration="200"/>
</animation-list>
b.layout文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@anim/animation_list"
android:paddingTop="50dp" >
</ImageView>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Run"
android:onClick="run">
</Button>
</LinearLayout>
c.layout文件
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.contextmenu);
imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setBackgroundResource(R.anim.animation_list);
// draw = (AnimationDrawable) imageView.getBackground();
draw = (AnimationDrawable) imageView.getDrawable();
registerForContextMenu(text);
}
public void run(View v) {
if (draw.isRunning()) {
draw.stop();
} else {
draw.stop();
draw.start();
}
}
分享到:
相关推荐
实现帧动画有两种方式,即xml和java 方法1:xml实现帧动画 第一步:导入帧动画素材 把准备的素材放到drawable目录 第三步:布局文件和Activity 布局文件:布局文件中添加两个点击按钮和一个图片控件 在...
Android 提供三种动画:帧动画、补间动画和属性动画,本篇文章介绍帧动画以及补间动画的使用,属性动画的使用将在后面的文章中分享,那就来复习一下这两种动画的使用吧。 FrameAnimation FrameAnimation 即逐帧动画...
2、创建android 2-2 AVD 3、运行configuration 4、分别根据luanch按钮来选择三个动画方式 5、如果一切正常,那么可以分别看到帧动画(frame-by-frame)、布局动画(layout animation)和视图动画(view animation) 目的:...
16.1.1 计划逐帧动画 16.1.2 创建活动 16.1.3 将动画添加到活动 16.2 布局动画 16.2.1 基本的补间动画类型 16.2.2 计划布局动画测试工具 16.2.3 创建活动和ListView 16.2.4 将ListView制作成...
16.1.1 计划逐帧动画 16.1.2 创建活动 16.1.3 将动画添加到活动 16.2 布局动画 16.2.1 基本的补间动画类型 16.2.2 计划布局动画测试工具 16.2.3 创建活动和ListView 16.2.4 将ListView制作成...
现如今的APP各式各样,同样也带来了各种需求,一个下拉刷新都能玩出花样了,前两天订饭的...Frame动画(帧动画),这一类动画可以创建一个Drawable序列,按照指定时间间歇一个一个显示出来。 Property动画(属性动画)
关键帧动画:为任何对象添加运动,使贴纸栩栩如生! 视频调整:控制亮度,对比度,饱和度,色相并提高视频质量 遮罩:轻松融合和合并视频 VivaCut Android版是一款视频编辑器,具有您需要的所有专业编辑工具!...
因为动画会以60帧/每秒的速度进行绘制。这意味着,这个方法每秒会被调用60次!所以,千万不要在这个方法中重复的创建对象,会卡爆的!原因是短时间的大量将会引起【内存抖动】,导致GC频繁发生。相关知识你可以看看...
2.2.2 Android开发环境 26 2.2.3 iOS开发环境 35 2.3 引擎中的混合编译 38 2.3.1 Java与C++的混合编译 38 2.3.2 Objective-C与C++的混合编译 41 2.4 引擎的启点 42 2.4.1 应用程序入口 43 2.4.2 引擎应用入口 44 2.5...
两个例子,无状态SessionBean可会话Bean必须实现SessionBean,获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,计算利息等;在有状态SessionBean中,用累加器,以对话状态存储起来,创建EJB对象,并将...
Java EJB中有、无状态SessionBean的两个例子 两个例子,无状态SessionBean可会话Bean必须实现SessionBean,获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,计算利息等;在有状态SessionBean中,用...
使用简便和直截了当,用户只需要加载的图片和调整帧您想要的,如位置,时间显示和处理方法前帧。 Java的PList类库 Blister Blister是一个用于操作苹果二进制PList文件格式的Java开源类库(可用于发送数据给iOS应用...
使用简便和直截了当,用户只需要加载的图片和调整帧您想要的,如位置,时间显示和处理方法前帧。 Java的PList类库 Blister Blister是一个用于操作苹果二进制PList文件格式的Java开源类库(可用于发送数据给iOS应用...
使用简便和直截了当,用户只需要加载的图片和调整帧您想要的,如位置,时间显示和处理方法前帧。 Java的PList类库 Blister Blister是一个用于操作苹果二进制PList文件格式的Java开源类库(可用于发送数据给iOS应用...
使用简便和直截了当,用户只需要加载的图片和调整帧您想要的,如位置,时间显示和处理方法前帧。 Java的PList类库 Blister Blister是一个用于操作苹果二进制PList文件格式的Java开源类库(可用于发送数据给iOS应用...