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. Oracle EBS-SQL (WIP-6):检查任务已完成但状态是发放的任务.sql

    select WE.WIP_ENTITY_NAME         ,MSI.SEGMENT1         ,MSI.DESCRIPTION         ,WDJ.CLASS_CODE     ...

  2. Webbrowser中模拟连接点击(非鼠标模拟)

    Delphi uses mshtml, ActiveX; //初始加载网易主页 procedure TForm1.FormCreate(Sender: TObject); begin Webbrows ...

  3. WampServer下如何实现多域名配置

    原文:WampServer下如何实现多域名配置 之前在学习跨域的时候,我写过一篇叫做WampServer下使用多端口访问的文章,默认的 localhost 采用的是 80 端口,能使用多端口访问的核心 ...

  4. php set env

    SYSTEM WARNING: 'date_default_timezone_get(): It is not safe to rely on the system's timezone settin ...

  5. Spring、整合Spring+JDBC

    首先引入Spring包和JDBC所使用到的包: 配置beans.xml步骤: 1.配置dataSource的属性 2.将DataSource交给DataSourceTransactionManager ...

  6. Android 弹出通知Toast的使用

    //官方帮助文档:http://wear.techbrood.com/guide/topics/ui/notifiers/toasts.html <LinearLayout xmlns:andr ...

  7. CSU - 1356 Catch(dfs染色两种写法,和hdu4751比较)

    Description A thief is running away! We can consider the city to N–. The tricky thief starts his esc ...

  8. Item with the same id "98" already exist

    在magento项目中多次遇到这样一个错误: Item (Bluecom_Onefieldusername_Model_Customer) with the same id "98" ...

  9. C-Free 您不能使用调试解决方案

    什么时候C-Free 当您调试 找不到gdb.exe解决方案 http://www.programarts.com/ C-Free 官方网站 下载Mingw或者其他编译器 版权声明:本文博主原创文章. ...

  10. VS2010在C盘下生成的.iTrace文件解决办法 ,c盘偷偷的减少,心很烦啊,找了半天才知道是这个问题

    用Visual Studio 2010后发现我的c盘变得越来越小了,刚开始通过优化工具清理c盘,但是无论怎么做都不能将c的内存有效提升,之后一个一个目录的查找之后才知道有个文件夹C:\ProgramD ...