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. 基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线!

    基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线! https://www.sohu.com/a/168292858_747818 https://github.com/ ...

  2. OpenWRT下实现Portal认证(WEB认证)

    首先简单介绍一下什么是Portal认证,Portal认证,通常也会叫Web认证,未认证用户上网时,设备强制用户登录到特定站点,用户可以免费访问其中的服务.当用户需要使用互联网中的其它信息时,必须在门户 ...

  3. python连接mysql实例分享_python

    示例一 #coding=UTF-8 import sys import MySQLdb import time reload(sys) sys.setdefaultencoding('utf-8') ...

  4. C# .Net计算函数执行的时间

    C#计算函数执行的时间 protected void StopwatchTest() { System.Diagnostics.Stopwatch stopwatch = new System.Dia ...

  5. 两种解决IE6不支持固定定位的方法

    有两种让IE6支持position:fixed1.用CSS执行表达式 *{margin:0;padding:0;} * html,* html body{ background-image:url(a ...

  6. JDK5.0特性-线程 Callable和Future

    来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291466.html import java.util.concurrent.Callable ...

  7. sell 项目 订单详情表 设计 及 创建

    1.数据库设计 2.订单详情表 创建 /** * 订单详情表 */ create table `order_detail` ( `detail_id` varchar(32) not null, `o ...

  8. [转]jquery设置select选中,赋值等操作

    一.基础取值问题 例如<select class="selector"></select> 1.设置value为pxx的项选中 $(".selec ...

  9. WCF 客户端 BasicHttpBinding 兼容 HTTPS 和 HTTP

    背景:全站HTTPS的时代来了 全站HTTPS,请参考:http://www.cnblogs.com/bugly/p/5075909.html 1. 设置BasicHttpBinding的BasicH ...

  10. javascript用正則表達式检測username的合法性

    在用户登录.用户注冊时经常须要对username如邮箱.手机号进行校验,一般经常使用表达式. 以下整理对邮箱和手机号的表达式校验: function checkUser(){ var userName ...