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. Java-Shiro(二):HelloWord

    新建项目&&配置pom.xml导入包 新建maven java project项目: 修改pom.xml: <project xmlns="http://maven.a ...

  2. 协程(Coroutine)并不是真正的多线程

    自:http://www.zhihu.com/question/23895384 说到Coroutine,我们必须提到两个更远的东西.在操作系统(os)级别,有进程(process)和线程(threa ...

  3. 'Lock wait timeout exceeded; try restarting transaction'问题

    OperationalError: (1205, 'Lock wait timeout exceeded; try restarting transaction') 原因很简单,太多错误,意外处理没有 ...

  4. [Spring Boot] Singleton and Prototype

    When we use Bean to do autowired, it actually use singleton, so even we create multi instanses, they ...

  5. 国内A股16家上市银行的財务数据与股价的因子分析报告(1)(工具:R)

    分析人:BUPT_LX 研究目的 用某些算法对2014年12月份的16家国内A股上市的商业银行当中11项財务数据(资产总计.负债合计.股本.营业收入.流通股A.少数股东权益.净利润.经营活动的现金流量 ...

  6. SuperMap开发入门4——保存的坑

    工作空间.地图等的打开.保存.删除是最基本的操作,可我居然卡在保存工作空间的问题上了. 功能需求 需求很简单:打开工作空间中的某一地图,缩放一下,保存地图.(下次打开时,已经缩放到上次修改过的地方) ...

  7. SHELL异常处理

    写SHELL好久了,经常被异常困扰,可竟然坚持了若干年没用过,回想以前服务过的公司,阿弥陀佛,罪过罪过.废话少说,希望此篇文章可以协助大家和我彻底结束SHELL脚本就是LINUX命令集合的初级阶段. ...

  8. 使用JAVA的URL类处理url事例

    import java.net.*; import java.io.*; public class ParseURL { public static void main(String[] args) ...

  9. …… are only available on JDK 1.5 and higher 错误

    "C:\Program Files\Java\jdk1.8.0_73\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 &q ...

  10. windows下安装mysql5.6

    1.   下载 http://dev.mysql.com/downloads/windows/installer/5.6.html 2.   安装 我们采用自定义安装模式:选择32位或64位 默认即可 ...