zoukankan      html  css  js  c++  java
  • 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.   
    8.   <EditText  
    9.       android:id="@+id/loading_editText_info"  
    10.       android:layout_width="0dp"  
    11.       android:layout_height="0dp" />  
    Java代码  收藏代码
    1. <pre class="java" name="code">  private ImageView loadingImageView ;  
    2.     private EditText loadingEditText;  
    3.     private AnimationDrawable anim;</pre>  
    4.    
    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.       
    5.     anim = (AnimationDrawable) loadingImageView.getBackground();  
    6.     loadingEditText.setOnFocusChangeListener(editSetOnFocus);  
    Java代码  收藏代码
    1. /** 
    2.          * 当输入框获取焦点,则运行动画 
    3.          */  
    4.         private  OnFocusChangeListener editSetOnFocus = new OnFocusChangeListener() {  
    5.               
    6.             @Override  
    7.             public void onFocusChange(View v, boolean hasFocus) {  
    8.                 // TODO Auto-generated method stub  
    9.                 anim.start();  
    10.                 Log.i("text", "执行等待动画。。。。。。。。");  
    11.             }  
    12.         };   

        当程序获取到数据一般情况是在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.   
    4.     <item android:duration="150" android:drawable="@drawable/load1" />   
    5.     <item android:duration="150" android:drawable="@drawable/load2" />   
    6.     <item android:duration="150" android:drawable="@drawable/load3" />   
    7.     <item android:duration="150" android:drawable="@drawable/load4" />   
    8.     <item android:duration="150" android:drawable="@drawable/load5" />   
    9.     <item android:duration="150" android:drawable="@drawable/load6" />   
    10.       
    11. </animation-list>   
  • 相关阅读:
    Git中tag标签的使用
    antd vue Layout 组件收缩展开自定义
    antd vue Popover气泡卡片的使用
    antd vue Tree树形控件的使用
    antd vue Message 全局提示的使用
    tp5.1 关联条件查询haswhere 用field限制字段失效的问题
    Chrome 调试技巧: 调整网速
    html2canvas导出图片模糊
    点击其他区域不让编辑器失去焦点
    启动的项目经常挂怎么办
  • 原文地址:https://www.cnblogs.com/xiaochao1234/p/4226879.html
Copyright © 2011-2022 走看看