png图片

代码

ImageView loading=getActivity().findViewById(R.id.pro_loading);

        LinearInterpolator lin = new LinearInterpolator();
am = new RotateAnimation ( 0, +360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f );
am. setDuration ( 1000 );//旋转一个周期的时长
am. setRepeatCount ( -1 );// 动画重复次数(-1 表示一直重复)
am.setRepeatCount(Animation.INFINITE);
am.setInterpolator(lin);
loading.setAnimation(am);
am.startNow();

因为有好多fragment要用到,所以封装了一下

终极类:

public class ProgressImageView extends ImageView {
private Animation am; public ProgressImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
} public ProgressImageView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
init();
} public ProgressImageView(Context context) {
super(context);
// TODO Auto-generated constructor stub
init();
} public void init(){
LinearInterpolator lin = new LinearInterpolator();
am = new RotateAnimation ( 0, +360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f );
am. setDuration ( 1000 );//旋转一个周期的时长
am. setRepeatCount ( -1 );// 动画重复次数(-1 表示一直重复)
am.setRepeatCount(Animation.INFINITE);
am.setInterpolator(lin);
} /**
* 显示
*/
public void show(){
setVisibility(View.VISIBLE);
this.setAnimation(am);
am.startNow();
} /**
*隐藏
*/
public void hide(){
this.clearAnimation();
setVisibility(View.INVISIBLE);
} }
        <com.lz.swc.view.ProgressImageView
android:id="@+id/pro_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loading"
android:layout_centerInParent="true"
android:contentDescription="@string/tabspic"
android:visibility="invisible"
/>

在xml中引用就可以了。调用 show hide方法即可

android 图片进度条的更多相关文章

  1. Android 设置进度条背景

    Android 设置进度条背景 直接上代码 <ProgressBar android:id="@+id/progressBar" android:layout_width=& ...

  2. android 自定义进度条颜色

    android 自定义进度条颜色 先看图 基于产品经理各种自定义需求,经过查阅了解,下面是自己对Android自定义进度条的学习过程!   这个没法了只能看源码了,还好下载了源码, sources\b ...

  3. Android之进度条2

    我之前有写过一篇“Android之进度条1”,那个是条形的进度条(显示数字进度),这次实现圆形进度条. 点击查看Android之进度条1:http://www.cnblogs.com/caidupin ...

  4. android的进度条使用

    android的进度条 1.实现的效果 2.布局代码 先写一个my_browser.xml文件 存放WebView <?xml version="1.0" encoding= ...

  5. android多线程进度条

    多线程实现更新android进度条. 实例教程,详细信息我已经注释   android多线程进度条   01package com.shougao.hello; 02 03import android ...

  6. 最简单的android自定义进度条样式

    一.自定义圆形进度条样式 1.在安卓项目drawable目录下新建一个xml文件如下:<?xml version="1.0" encoding="utf-8&quo ...

  7. Android多种进度条使用详解

    在这里,总结一下loading进度条的使用简单总结一下. 一.说起进度条,必须说说条形进度条,经常都会使用到嘛,特别是下载文件进度等等,还有像腾讯QQ安装进度条一样,有个进度总给人良好的用户体验. 先 ...

  8. android ProgressBar 进度条的进度两端是圆角的方法

    转自 http://www.jianshu.com/p/6e7ea842d5ce 另外工作原理可以参考http://blog.csdn.net/lan603168/article/details/44 ...

  9. Android loading进度条使用简单总结

    在这里,总结一下loading进度条的使用简单总结一下. 一.说起进度条,必须说说条形进度条,经常都会使用到嘛,特别是下载文件进度等等,还有像腾讯QQ安装进度条一样,有个进度总给人良好的用户体验. 先 ...

随机推荐

  1. [强连通分量] POJ 1236 Network of Schools

    Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16803   Accepted: 66 ...

  2. ets查询:查询表中的具体一列的所有值

    比如要查询goods表中的ID这一列的所有值: P = [{#goods{upgrade='$1',_ = '_'},[],['$1']}] 要查询ID和Upgrade这两列的值: P2 = [{#g ...

  3. HDU 4939 Stupid Tower Defense (2014 Multi-University Training Contest 7)

    思路:首先红色肯定要放在最后面.前面蓝色和绿色dp求解. dp[i][j]  表示前面(i+j) 个 有 i 个蓝色塔  j个绿色塔 能造成最大伤害. //====================== ...

  4. swiper 内容超出纵向滚动 解决办法

    .swiper-slide { overflow: auto; }   var swiper = new Swiper('.swiper-container', { direction: 'verti ...

  5. Linux 编译 websocket++

    下载boost 库wget -O boost_last.zip http://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_ ...

  6. 在Eclipse上建立hadoop2.2.0/hadoop2.4.0源代码阅读环境

    1.安装依赖的包: yum install gcc-c++ g++ autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev 2 ...

  7. CSS属性之 -- overflow

    overflow可以实现隐藏超出对象内容,同时也有显示与隐藏滚动条的作用,overflow属性有四个值:visible (默认), hidden, scroll, 和auto.同样有两个overflo ...

  8. 关于ADDED_TO_STAGE事件

    可视类初始化的时候,很多时候要用到stage属性,则要使用Event.ADDED_TO_STAGE事件,这个swf被其它的文件加载,如果直接在初始化函数内使用stage属性 .但是,文档类初始化函数内 ...

  9. UITableView使用的一些技巧

    1.如果想自己在视图中加一条线,和UITableView的cell的分割线颜色粗细一样,那么可以: UIView *lineView = [[UIView alloc] initWithFrame:C ...

  10. Qt之WebKit学习之绘图

    void Serial::on_pushButton_clicked() { //scroll(4,0); flag_btn = true; // this->update(); //绘图绘在窗 ...