android image加载中等待动画

Xml代码  

  1. 在布局中添加一个ImageViw和一个EditText。

Xml代码  

  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" />

Java代码  

  1. <pre class="java" name="code">  private ImageView loadingImageView ;
  2. private EditText loadingEditText;
  3. private AnimationDrawable anim;</pre>

Java代码  

  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);

Java代码  

  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中发送消息通知动画停止,并隐藏当前的控件

Java代码  

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

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

Java代码  

  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>
时间: 2024-08-26 07:12:38

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

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

<!DOCTYPE html> <html> <head> <title>css实现页面加载中,请稍候效果</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my pa

CSS3实现加载中的动画效果

本篇文章由:http://xinpure.com/css3-implementations-of-loading-an-animation-effect/ Loading 的菊花图形组合的不太好,基本上实现这个功能了 动画解析 这个动画用到的 CSS3 特性: transform 主要使用 transform 属性的 rotate,将线条组合成 Loading 图形 (也就是常见的菊花图形) animation 实现将线条颜色由浅到深,再由深到浅来回变换的动画,通过 animation-dela

css3动画-加载中...

写几个简单的加载中动画吧. 像前面三种都是相当于几个不同的点轮流来播放同一动画:变大变小.css3里面有一个用于尺度变换的方法:scale(x,y):定义 2D 缩放转换,改变元素的宽度和高度. 第四种就是一个小球从上往下跌落,再弹回去,在上面的时候速度最小,下面的时候速度最大.由于该小球只进行了上下的移动,所以我们可以运用:translateY(n):定义 2D 转换,沿着 Y 轴移动元素,从而实现小球沿Y方向来回移动. 废话不多说了,上代码. 首先,第一个加载中的动画: 1 <div id=

Android异步加载全解析之Bitmap

Android异步加载全解析之Bitmap 在这篇文章中,我们分析了Android在对大图处理时的一些策略--Android异步加载全解析之大图处理  戳我戳我 那么在这篇中,我们来对图像--Bitmap进行一个更加细致的分析,掌握Bitmap的点点滴滴. 引入 Bitmap这玩意儿号称Android App头号杀手,特别是3.0之前的版本,简直就是皇帝般的存在,碰不得.摔不得.虽然后面的版本Android对Bitmap的管理也进行了一系列的优化,但是它依然是非常难处理的一个东西.在Androi

Android应用之——仿美团loading加载中动画

前言 想必用过美团客户端的用户对美团那个加载小人的动画印象很深刻,一个可爱的小人在那拼命的跑.这个动画实现的方法其实很多,今天这里就用frame动画来实现一下. 一.效果图 二.布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_w

简单的“加载中”动画效果

在日常开发过程中,处理一些延迟操作的时候,经常需要显示一个"加载中"对话框来来表示程序正在请求或正在处理.那么如何写一个最简单的动画效果呢? 这里我写了个demo: MainActivity: public class MainActivity extends Activity {     //ProgressDialog用于显示加载对话框用     private ProgressDialog progressDialog = null;     //显示结果用     privat

android 实现加载动画对话框

先来两张效果图        自定义对话框: public class LoadingProgressDialog extends ProgressDialog { private AnimationDrawable mAnimation; private Context mContext; private ImageView mImageView; private String mLoadingTitle; private TextView mLoadingTv; private int mR

用C3中的animation和transform写的一个模仿加载的时动画效果

用用C3中的animation和transform写的一个模仿加载的时动画效果! 不多说直接上代码; html标签部分 <div class="wrap"> <h2>用C3中的animation和transform写的一个模仿加载的时动画效果</h2> <div class="demo"> <div></div> <div></div> <div></d

【转载】cocos2dx 中 Android NDK 加载动态库的问题

原文地址:http://blog.csdn.net/sozell/article/details/10551309 cocos2dx 中 Android NDK 加载动态库的问题 闲聊 最近在接入各个平台的SDK,遇到了不少问题,也从中了解了不少知识,之前一直觉得没啥好写的,毕竟做了4个月的游戏开发,也没有碰上什么真正的大问题,cocos2dx的引擎包得也很好,能让人把大部分时间都关注在游戏逻辑.效果的处理上,当然,之前的libevent还是小坑一下,但是和后来遇到的相比,也算不上什么了. 我最