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. SharePoint 2010/2013: List view Lookup threshold uncovered

    SharePoint with Large lists is common scenario in any Sharepoint deployment. While there are Several ...

  2. CSOM中如何取到managed metadata类型字段的类型信息

    Field.fieldTypeKind返回的是Invalid [解决方法] There is no "Metadata" type of field in the SP.Field ...

  3. junit mockito

    package com.zendaimoney.util; import static org.mockito.Mockito.*;import static org.junit.Assert.*;i ...

  4. Android Studio中关于9-patch格式图片的编译错误

    最近在编译Android Studio开发的项目中在使用了9宫图后出现了编译错误,尝试了多种方法未能解决,最后仔细查看出错的日志发现,居然是图片的原因,图片中包含有alpah通道所以在执行app:me ...

  5. phpMyadmin安装极简教程[下载,解压,登录]

    1.下载一个压缩包,例如: 2. 解压到web根目录并重命名为phpmyadmin 3.在浏览器输入http://localhost/phpmyadmin就可以看到登陆界面了,登陆之后,数据库,表的增 ...

  6. ZH奶酪:如何在Ubuntu上安装Java/管理多个JAVA/设置JAVA_HOME

    0.简介 Java的地位及重要性,大家都懂的,很多软件都依赖于jdk,在Ubuntu上安装Java的选择有很多,openJDK,Oracle Jdk... 1.安装默认 JRE/JDK(可选) 这是最 ...

  7. HOW TO: Synchronize changes when completing a P2V or V2V with VMware vCenter Converter Standalone 5.1

    http://www.experts-exchange.com/Software/VMWare/A_11489-HOW-TO-Synchronize-changes-when-completing-a ...

  8. Linux中进程与线程及CPU使用率查询

    一.进程查询: ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' 说明:PCPU是Cpu使用率,8核最多是800. 或者 ps -aux 二.线 ...

  9. Android开之在非UI线程中更新UI

    当在非UI线程中更新UI(程序界面)时会出现例如以下图所看到的的异常: 那怎样才干在非UI线程中更细UI呢? 方法有非常多种.在这里主要介绍三种: 第一种:调用主线程mHandler的post(Run ...

  10. 【BI】OLTP与OLAP的区别

    概念 OLTP:联机事务处理(On-Line transaction Processing) OLAP:联机分析处理(On-Line Analytical Processing) (1)OLTP是传统 ...