1. 在布局中添加一个ImageViw和一个EditText。
  1. <ImageView
  2. android:id="@+id/loading_imageView_info"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:layout_gravity="center"
  6. android:background="@anim/loading" />
  7. <EditText
  8. android:id="@+id/loading_editText_info"
  9. android:layout_width="0dp"
  10. android:layout_height="0dp" />
  1. <pre class="java" name="code">  private ImageView loadingImageView ;
  2. private EditText loadingEditText;
  3. private AnimationDrawable anim;</pre>
  1. loadingImageView =(ImageView)findViewById(R.id.loading_imageView_info);
  2. loadingEditText =(EditText)findViewById(R.id.loading_editText_info);
  3. loadingEditText.setInputType(InputType.TYPE_NULL);//屏蔽软键盘
  4. anim = (AnimationDrawable) loadingImageView.getBackground();
  5. loadingEditText.setOnFocusChangeListener(editSetOnFocus);
  1. /**
  2. * 当输入框获取焦点,则运行动画
  3. */
  4. private  OnFocusChangeListener editSetOnFocus = new OnFocusChangeListener() {
  5. @Override
  6. public void onFocusChange(View v, boolean hasFocus) {
  7. // TODO Auto-generated method stub
  8. anim.start();
  9. Log.i("text", "执行等待动画。。。。。。。。");
  10. }
  11. };

当程序获取到数据一般情况是在hanlder中发送消息通知动画停止,并隐藏当前的控件

  1. anim.stop();
  2. loadingImageView.setVisibility(View.GONE);

anim动画在XML中定义,代码如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
  3. <item android:duration="150" android:drawable="@drawable/load1" />
  4. <item android:duration="150" android:drawable="@drawable/load2" />
  5. <item android:duration="150" android:drawable="@drawable/load3" />
  6. <item android:duration="150" android:drawable="@drawable/load4" />
  7. <item android:duration="150" android:drawable="@drawable/load5" />
  8. <item android:duration="150" android:drawable="@drawable/load6" />
  9. </animation-list>

android image加载中等待动画的更多相关文章

  1. css 实现页面加载中等待效果

    <!DOCTYPE html> <html> <head> <title>css实现页面加载中,请稍候效果</title> <meta ...

  2. [TimLinux] CSS 实现加载中的动画

    内容来自对<CSS世界>学习代码的理解简化: <!DOCTYPE html> <html> <head> <style> div { pad ...

  3. android dialog加载中动画效果

    //显示动画 dialog = new Dialog(context, R.style.loading); dialog.setContentView(R.layout.loadinglayout); ...

  4. CSS3实现加载中的动画效果

    本篇文章由:http://xinpure.com/css3-implementations-of-loading-an-animation-effect/ Loading 的菊花图形组合的不太好,基本 ...

  5. css3动画-加载中...

    写几个简单的加载中动画吧. 像前面三种都是相当于几个不同的点轮流来播放同一动画:变大变小.css3里面有一个用于尺度变换的方法:scale(x,y):定义 2D 缩放转换,改变元素的宽度和高度. 第四 ...

  6. Android 菊花加载工具类

    先看看实现效果图 1.首先自定义一个类继承系统ProgressDialog /** * Created by hanbao0928 on 2018/11/1. */ public class Dial ...

  7. adnroid 自定义ProgressDialog加载中

    用来记录自己所用到的知识 前两天在做项目的时候发现有时候在访问网络数据的时候由于后台要做的工作较多,给我们返回数据的时间较长,所以老大叫我加了一个加载中的logo图用来提高用户体验. 于是就在网上找了 ...

  8. Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果)

    Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果) 首句依然是那句老话,你懂得! finddreams :(http://blog.csdn.net/finddr ...

  9. 漂亮的Android加载中动画:AVLoadingIndicatorView

    AVLoadingIndicatorView 包含一组漂亮的Android加载中动画. IOS版本:here. 示例 Download Apk 用法 步骤1 Add dependencies in b ...

随机推荐

  1. Spring(八):Spring配置Bean(一)BeanFactory&ApplicationContext概述、依赖注入的方式、注入属性值细节

    在Spring的IOC容器里配置Bean 配置Bean形式:基于xml文件方式.基于注解的方式 在xml文件中通过bean节点配置bean: <?xml version="1.0&qu ...

  2. (转)unity3D 如何提取游戏资源 (反编译)+代码反编译

    原帖:http://bbs.9ria.com/thread-401140-1-1.html 首先感谢 雨松MOMO 的一篇帖子 教我们怎么提取 .ipa 中的游戏资源.教我们初步的破解unity3d资 ...

  3. mongodb最大连接数、最大连接数修改

        mongodb最大连接数是20000. 所以业界流传一段话,千万级以下的用mysql.千万级以上的用mongodb,亿级以上的用hadoop.   查看mongodb最大连接数 mongodb ...

  4. php composer工具高速使用教程,超级简单

    php依赖管理工具.用于处理packages或者libraries.基于单个工程project,在project的vender目录下保存,默认永远不会全局安装. 须要php 5.3.2+,安装资源包时 ...

  5. Asp.NET MVC 之 调试访问 webservice 时出现“ 无法找到资源 ”的错误

    问题情景如标题,具体错误如下图: 出现以上情况,是程序将 .asmx 文件按控制器方式解析了,在 RouteConfig.cs 文件的 RegisterRoutes 方法中忽略 .asmx 文件,&q ...

  6. http 请求报文

    1.报文 2.http请求方法 restful接口 post:创建 put:更新

  7. Linux上实现Windows的SQLPlus保存SQL历史记录功能

    在Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重新提交执行. 然而,当在L ...

  8. C++11中的mutex, lock,condition variable实现分析

    本文分析的是llvm libc++的实现:http://libcxx.llvm.org/ C++11中的各种mutex, lock对象,实际上都是对posix的mutex,condition的封装.不 ...

  9. 【DB2】监控临时表空间使用

    在我们使用数据库的时候,我们都知道应用程序在DB2上运行时,会产生临时表空间,我们想要监测这些临时表空间的使用情况,可以使用以下步骤: (1)打开monitor switches 中的table监视器 ...

  10. mysql取电话号码的后四位字符

    SELECT id, RIGHT (phone,4)  from user  where  id= 'xxxxxx'