<pre name="code" class="java">在上篇文章中介绍了模拟登录服务器时出现的加载对话框,不过是使用android 默认的Dialog,那么我们如果想用自己定义的怎么实现呢?下面先讲android的帧动画:
首先是新建一项目,然后在res底下新建一个anim文件夹,新建一个frame.xml(名称自取)文件,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!--animation-list 动画帧列表 item:每一帧,duration="200" 200毫秒,0.2秒,根据自己情况可以调节 -->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/img01"
android:duration="200"/>
<item
android:drawable="@drawable/img02"
android:duration="200"/>
<item
android:drawable="@drawable/img03"
android:duration="200"/>
<item
android:drawable="@drawable/img04"
android:duration="200"/>
<item
android:drawable="@drawable/img05"
android:duration="200"/>
<item
android:drawable="@drawable/img06"
android:duration="200"/>
<item
android:drawable="@drawable/img07"
android:duration="200"/>
<item
android:drawable="@drawable/img08"
android:duration="200"/>
</animation-list>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context="com.example.animationtest.MainActivity" >
<ImageView
android:id="@+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@anim/frame"/>
<TextView
a