Android doesn’t handle animated gifs, but here’s one way to display an animated loading image that is similar to the Spinner style of ProgressDialog.

Image Files:

Loading Images

drawable/loading.xml

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/loading_1" android:duration="100" />
<item android:drawable="@drawable/loading_2" android:duration="100" />
<item android:drawable="@drawable/loading_3" android:duration="100" />
<item android:drawable="@drawable/loading_4" android:duration="100" />
<item android:drawable="@drawable/loading_5" android:duration="100" />
<item android:drawable="@drawable/loading_6" android:duration="100" />
<item android:drawable="@drawable/loading_7" android:duration="100" />
<item android:drawable="@drawable/loading_8" android:duration="100" />
<item android:drawable="@drawable/loading_9" android:duration="100" />
<item android:drawable="@drawable/loading_10" android:duration="100" />
<item android:drawable="@drawable/loading_11" android:duration="100" />
<item android:drawable="@drawable/loading_12" android:duration="100" />
</animation-list>

MyActivity.java

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class MyActivity extends Activity {

ImageView loading;
AnimationDrawable loadAnimation;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
LinearLayout main = new LinearLayout(this);
main.setOrientation(LinearLayout.VERTICAL);
setContentView(main);

loading = new ImageView(this);
loading.setImageResource(R.drawable.loading);
loadAnimation = (AnimationDrawable)loading.getDrawable();
main.addView(loading);

}

//can't start animating in OnCreate, so start when window becomes in focus
@Override
public void onWindowFocusChanged(boolean hasFocus){

loadAnimation.start();

}

}

Loading Image的更多相关文章

  1. 步入angularjs directive(指令)--点击按钮加入loading状态

    今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...

  2. 《动手实现一个网页加载进度loading》

    loading随处可见,比如一个app经常会有下拉刷新,上拉加载的功能,在刷新和加载的过程中为了让用户感知到 load 的过程,我们会使用一些过渡动画来表达.最常见的比如"转圈圈" ...

  3. eclipse 突然 一直在loading descriptor for XXX (XXX为工程名)Cancel Requested

    问题: eclipse 启动后,啥也不干,就一直在loading descriptor for XXX (XXX为工程名),,其他什么操作都不能操作. 如下图所示,保存文件也无法保存.  这个怎么办? ...

  4. linux使用wkhtmltopdf报错error while loading shared libraries:

    官网提示 linux需要这些动态库.depends on: zlib, fontconfig, freetype, X11 libs (libX11, libXext, libXrender) 在li ...

  5. solr定时更新索引遇到的问题(SolrDataImportProperties Error loading DataImportScheduler properties java.lang.NullPointerException)

    问题描述 报如下错误,很显然,问题原因:空指针异常: ERROR (localhost-startStop-1) [   ] o.a.s.h.d.s.SolrDataImportProperties ...

  6. python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory

    安装python3遇到报错: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz ./configure --prefix=/u ...

  7. x01.os.21: print "Loading..."

    Linux Inside 是中文版,值得下载一读. 先把目标设低点,开机进入后,在屏幕上打印“Loading..."即可.由于要在 bochs 中运行,首先就是安装 bochs.Oldlin ...

  8. 利用animation和text-shadow纯CSS实现loading点点点的效果

    经常在网上看到loading状态时的点点点的动态效果,自己也用JS写了一个,思路是使用一个计数参数,然后在需要添加点的元素后面利用setInterval一个一个加点,当计数到3时,把点变为一个--写完 ...

  9. 项目中运行报错: Loading XML bean definitions from class path resource [applicationContext.xml]

    记录一下: org.springframework.context.support.AbstractApplicationContext prepareRefresh Refreshing org.s ...

  10. 一个简单实用的css loading图标

    摘要 在web开发中,为了提高用户体验,在加载数据的时候都会给一个loading的提示. Html <!DOCTYPE html> <html xmlns="http:// ...

随机推荐

  1. Linux Syslog

    http://blog.chinaunix.net/uid-677314-id-164215.html http://blog.chinaunix.net/uid-24708340-id-397132 ...

  2. 论山寨手机与Android 【12】3G时代SmartPhone BP部分

    最成熟的3G网络系统,是3GPP项目组制订的WCDMA.WCDMA的网络结构,可参考Figure 12.1,其中有几个特点. 1. 反向兼容GSM/GRPS网络. 原有GSM网络的基站子系统(BSS) ...

  3. NOR和NAND flash区别,RAM 和ROM区别

    ROM是Read Only Memory的缩写.RAM是Random Access Memory的缩写.典型的RAM就是计算机的内存. RAM有两大类,一种称为静态RAM(Static RAM/SRA ...

  4. schema://host[:port#]/path/.../[?query-string][#anchor]

    1:http协议状态200 OK最常见的就是成功响应状态码200了, 这表明该请求被成功地完成,所请求的资源发送回客户端 302 Found重定向,新的URL会在response 中的Location ...

  5. Android AndroidManifest 清单文件以及权限详解!【转】

    转自:http://my.oschina.net/yuanxulong/blog/366753 每个Android应用都需要一个名为AndroidManifest.xml的程序清单文件,这个清单文件名 ...

  6. 简单QT界面信号图形化输入输出

    右键->转到槽,选择信号 就可以输入代码 右键->转到槽,选择信号 就可以输入代码 2个文本框接受输入数字,第3个文本框输出相加结果 void Dialog::on_pushButton_ ...

  7. #include <stdio.h>

    1 fflush 2 fgetc 3 fgets 4 fprintf 5 fputc 6 fputs 7 fscanf 8 fseek 9 ftell 10 perror 11 remove 12 r ...

  8. wx

    wx The classes in this module are the most commonly used classes for wxPython, which is why they hav ...

  9. react-native component function

    examples: use:

  10. The Unique MST (判断是否存在多个最小生成树)

    The Unique MST                                                                        Time Limit: 10 ...