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. OC中intValue要注意的地方

    在程序中,发现一个问题,写了个例子,如下:         NSDictionary * dict = [[NSDictionary alloc] init];        NSString * s ...

  2. CSS3特性 盒模型 动画

    转发自0101后花园 CSS3中的动画功能分为Transitions和Animations功能,这两种功能都可以通过改变CSS中的属性值来产生动画效果. 一.Transitions 语法:transi ...

  3. [Java Basics] Collection

    除了Java collection class/interface外,方便的有Google guava的utility class: Lists/Sets/Maps/Queues, 用它们可以方便地创 ...

  4. linux命令:head

    1.命令介绍: head用来显示文件的开头的一部分. 2.命令格式: head [选项] 文件 3.命令参数: -q 隐藏文件名 -v 显示文件名 -c<字节> 显示字节数 -n<行 ...

  5. 【LeetCode OJ】Path Sum

    Problem Link: http://oj.leetcode.com/problems/path-sum/ One solution is to BFS the tree from the roo ...

  6. A strange lift_BFS

    Problem Description There is a strange lift.The lift can stop can at every floor as you want, and th ...

  7. 传智播客JavaWeb day03

    ServletContext 这堂课主要讲ServletContext这个web域(可以看得见范围的)对象,web在启动的时候会创建唯一的ServletContext域对象. 作用:1.用来web域共 ...

  8. oop、try_except、单例模式

    本节大纲: 面向对象特性:封装.继承.多态.一:多态:python本身是多态,他的参数可以多种类型.可以是字符串.数字.列表等.当传入参数的时候,python可以判断参数的数据类型.而在java C# ...

  9. 第八课,T语言功能和参数(版本5.0)

    功能的理解 功能是TC移动项目应用的基本模块,通过对功能模块的调用实现特定的功能.TC综合开发工具中的功能相当于其它高级语言的子程序,在其他高级语言中,比如C,C++中,称为函数.允许用户建立自己定义 ...

  10. 论文笔记之:A CNN Cascade for Landmark Guided Semantic Part Segmentation

    A CNN Cascade for Landmark Guided Semantic Part Segmentation  ECCV 2016 摘要:本文提出了一种 CNN cascade (CNN ...