- 浏览: 85454 次
- 性别:
- 来自: 北京
最新评论
-
LiuYiJie2007:
public static String getPublicK ...
Android publickey获取 -
LiuYiJie2007:
getPublicKey( )是你自己写法方法 是什么?new ...
Android publickey获取 -
liujia9234:
我试了,不行,最不靠谱了
最靠谱的禁止ViewPager滑动方法 -
kedongjun:
非常强大
关于android通讯录加载大数据的优化问题 -
xunhuan01:
view.getImageMatrix(), savedMat ...
多点触摸放大图片的自定义listener
圆形不滚动的进度条
- 博客分类:
- android技术文章
这种效果的进度条 代码如下:
package com.netqin.antivirus.ui; import android.content.Context; import android.content.res.TypedArray; import android.graphics.*; import android.os.Handler; import android.os.Message; import android.util.AttributeSet; import android.util.Log; import android.widget.ImageView; import com.nqmobile.antivirus20.R; import java.util.Timer; import java.util.TimerTask; public class RoundProgressBar extends ImageView { private Paint mFramePaint; //-------------------- private Paint mRoundPaints; // 主进度条画笔 private RectF mRoundOval; // 矩形区域 private int mPaintWidth; // 画笔宽度 private int mPaintColor; // 画笔颜色 private int mBottomColor;//进度条背景色 private int mStartProgress; // 进度条起始位置 private int mCurProgress; // 主进度条当前位置 private int mMaxProgress; // 进度条最终位置 private boolean mBRoundPaintsFill; // 是否填充区域 //--------------------- private int mSidePaintInterval; // 圆环向里缩进的距离 private Paint mSecondaryPaint; // 辅助进度条画笔 private int mSecondaryCurProgress; // 辅助进度条当前位置 private Paint mBottomPaint; // 进度条背景图画笔 private boolean mBShowBottom; // 是否显示进度条背景色 //---------------------- private Handler mHandler; private boolean mBCartoom; // 是否正在作动画 private Timer mTimer; // 用于作动画的TIMER private MyTimerTask mTimerTask; // 动画任务 private int mSaveMax; // 在作动画时会临时改变MAX值,该变量用于保存值以便恢复 private int mTimerInterval; // 定时器触发间隔时间(ms) private float mCurFloatProcess; // 作动画时当前进度值 private float mProcessRInterval; // 作动画时每次增加的进度值 private final static int TIMER_ID = 0x100; // 定时器ID private long mCurTime; public RoundProgressBar(Context context) { super(context); initParam(); } public RoundProgressBar(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub initParam(); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RoundProgressBar); mMaxProgress = array.getInt(R.styleable.RoundProgressBar_max, 100); mSaveMax = mMaxProgress; mBRoundPaintsFill = array.getBoolean(R.styleable.RoundProgressBar_fill, true); // 获得是否是填充模式 if (mBRoundPaintsFill == false) { mRoundPaints.setStyle(Paint.Style.STROKE); mSecondaryPaint.setStyle(Paint.Style.STROKE); mBottomPaint.setStyle(Paint.Style.STROKE); } mSidePaintInterval = array.getInt(R.styleable.RoundProgressBar_inside_interval, 0);// 圆环缩进距离 mBShowBottom = array.getBoolean(R.styleable.RoundProgressBar_show_bottom, true); mPaintWidth = array.getInt(R.styleable.RoundProgressBar_paint_width, 10); if (mBRoundPaintsFill) // 填充模式则画笔长度改为0 { mPaintWidth = 0; } mRoundPaints.setStrokeWidth(mPaintWidth); mSecondaryPaint.setStrokeWidth(mPaintWidth); mBottomPaint.setStrokeWidth(mPaintWidth); mPaintColor = array.getColor(R.styleable.RoundProgressBar_paint_color, 0xffffcc00); mBottomColor = array.getColor(R.styleable.RoundProgressBar_paint_bottom_color, Color.WHITE); mRoundPaints.setColor(mPaintColor); int color = mPaintColor & 0x00ffffff | 0x66000000; mSecondaryPaint.setColor(color); array.recycle(); //一定要调用,否则会有问题 } private void initParam() { mFramePaint = new Paint(); mFramePaint.setAntiAlias(true); mFramePaint.setStyle(Paint.Style.STROKE); mFramePaint.setStrokeWidth(0); mPaintWidth = 0; mPaintColor = 0xffffcc00; mRoundPaints = new Paint(); mRoundPaints.setAntiAlias(true); mRoundPaints.setStyle(Paint.Style.FILL); mRoundPaints.setStrokeWidth(mPaintWidth); mRoundPaints.setColor(mPaintColor); mSecondaryPaint = new Paint(); mSecondaryPaint.setAntiAlias(true); mSecondaryPaint.setStyle(Paint.Style.FILL); mSecondaryPaint.setStrokeWidth(mPaintWidth); int color = mPaintColor & 0x00ffffff | 0x66000000; mSecondaryPaint.setColor(color); mBottomPaint = new Paint(); mBottomPaint.setAntiAlias(true); mBottomPaint.setStyle(Paint.Style.FILL); mBottomPaint.setStrokeWidth(mPaintWidth); mBottomPaint.setColor(mBottomColor); mStartProgress = -90; mCurProgress = 0; mMaxProgress = 100; mSaveMax = 100; mBRoundPaintsFill = true; mBShowBottom = true; mSidePaintInterval = 0; mSecondaryCurProgress = 0; mRoundOval = new RectF(0, 0, 0, 0); mTimerInterval = 25; mCurFloatProcess = 0; mProcessRInterval = 0; mBCartoom = false; mHandler = new Handler() { public void handleMessage(Message msg) { if (msg.what == TIMER_ID) { if (mBCartoom == false) { return ; } mCurFloatProcess += mProcessRInterval; setProgress((int) mCurFloatProcess); if (mCurFloatProcess > mSaveMax) { mBCartoom = false; setProgress(mSaveMax); if (mTimerTask != null) { mTimerTask.cancel(); mTimerTask = null; } } } } }; mTimer = new Timer(); } public synchronized void setProgress (int progress) { mCurProgress = progress; if (mCurProgress < 0) { mCurProgress = 0; } if (mCurProgress > mMaxProgress) { mCurProgress = mMaxProgress; } invalidate(); } public synchronized int getProgress() { return mCurProgress; } public synchronized void setSecondaryProgress (int progress) { mSecondaryCurProgress = progress; if (mSecondaryCurProgress < 0) { mSecondaryCurProgress = 0; } if (mSecondaryCurProgress > mMaxProgress) { mSecondaryCurProgress = mMaxProgress; } invalidate(); } public synchronized int getSecondaryProgress() { return mSecondaryCurProgress; } public synchronized void setMax(int max) { if (max <= 0) { return ; } mMaxProgress = max; if (mCurProgress > max) { mCurProgress = max; } if (mSecondaryCurProgress > max) { mSecondaryCurProgress = max; } mSaveMax = mMaxProgress; invalidate(); } public synchronized int getMax() { return mMaxProgress; } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { // TODO Auto-generated method stub super.onSizeChanged(w, h, oldw, oldh); Log.i("", "W = " + w + ", H = " + h); if (mSidePaintInterval != 0) { mRoundOval.set(mPaintWidth/2 + mSidePaintInterval, mPaintWidth/2 + mSidePaintInterval, w - mPaintWidth/2 - mSidePaintInterval, h - mPaintWidth/2 - mSidePaintInterval); }else{ int sl = getPaddingLeft(); int sr = getPaddingRight(); int st = getPaddingTop(); int sb = getPaddingBottom(); mRoundOval.set(sl + mPaintWidth/2, st + mPaintWidth/2, w - sr - mPaintWidth/2, h - sb - mPaintWidth/2); } } public synchronized void startAnimation(int time, int progresLenght) { if (time <= 0 || mBCartoom == true) { return ; } mBCartoom = true; if (mTimerTask != null) { mTimerTask.cancel(); mTimerTask = null; } setProgress(0); setSecondaryProgress(0); mSaveMax = progresLenght; mMaxProgress = (1000 / mTimerInterval) * time; mProcessRInterval = (float)mTimerInterval * mMaxProgress / (time * 1000); mCurFloatProcess = 0; mCurTime = 0; mTimerTask = new MyTimerTask(); mTimer.schedule(mTimerTask, mTimerInterval, mTimerInterval); } public void setShaperColors(int[] colors){ if (null != colors){ LinearGradient mLinearGradient = new LinearGradient(0,0,100,100,colors,null,Shader.TileMode.REPEAT); mRoundPaints.setShader(mLinearGradient); } } public synchronized void stopAnimation() { mBCartoom = false; mMaxProgress = mSaveMax; setProgress(0); if (mTimerTask != null) { mTimerTask.cancel(); mTimerTask = null; } } public void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); if (mBShowBottom) { canvas.drawArc(mRoundOval, 0, 360, mBRoundPaintsFill, mBottomPaint); } float secondRate = (float)mSecondaryCurProgress / mMaxProgress; float secondSweep = 360 * secondRate; canvas.drawArc(mRoundOval, mStartProgress, secondSweep, mBRoundPaintsFill, mSecondaryPaint); float rate = (float)mCurProgress / mMaxProgress; float sweep = 360 * rate; canvas.drawArc(mRoundOval, mStartProgress, sweep, mBRoundPaintsFill, mRoundPaints); } class MyTimerTask extends TimerTask{ @Override public void run() { Message msg = mHandler.obtainMessage(TIMER_ID); msg.sendToTarget(); } } }
发表评论
-
Android_低版本使用ActionBar
2014-08-26 11:09 1066转载 http://blog.csdn.net/tianjf0 ... -
如何屏蔽android webview高度选中框
2014-02-19 12:04 711如标题所述,解决方法是在 html的样式中加入 *{-webk ... -
屏蔽ScrollView惯性滚动的方法
2013-08-08 13:36 5666ScrollView中有一种惯性滚动的效果,想让这个Scrol ... -
android 图片LOMO效果
2013-07-25 13:59 842import android.graphics.Bitmap; ... -
GitHub最火的android 项目
2013-07-25 13:14 751GitHub在中国的火爆程度无需多言,越来越多的开源项目迁移到 ... -
listview 点击列表项时,项中的Button会触发点击效果
2013-06-05 19:21 1250开发中,难免会在列表项中, 加入Button ,而button ... -
最靠谱的禁止ViewPager滑动方法
2013-05-15 14:44 4919最近做项目要求某种情况下ViewPager不能滑动,在网上找了 ... -
viewpager主页面响应子页面 onkeydown事件的方法
2013-05-13 19:35 1550大家在开发中不少地方要用到ViewPager这个类,ViewP ... -
Mina 学习笔记 TCP主要接口
2013-05-05 23:21 1173(1.)IoService: 这个接口 ... -
android动画插件器
2013-04-27 10:01 782首先要了解为什么需要插值器,因为在补间动画中,我们一般只定义关 ... -
imageView 的 android:maxHeight,maxWidth属性
2013-03-29 10:17 777大家使用android:maxHeight,maxWidth属 ... -
android中获取下载地址文件的类型的方法
2013-03-28 11:33 976MimeTypeMap mimeTypeMap = Mime ... -
res与res-auto的区别
2013-03-27 14:55 3921通常我们在布局文件中使用自定义属性的时候 会这样写 xmln ... -
滑动开关控件
2013-03-26 22:39 758public class SlidButton exten ... -
TextView使用SpannableString设置复合文本
2013-03-23 23:35 8381、BackgroundColorSpan 背景色 Sp ... -
Android编程之SparseArray<E>详解
2013-03-21 23:03 941一、构造 从构造方法我 ... -
判断系统是否支持 DownloadManager服务
2013-03-18 14:25 816public static boolean isDownloa ... -
android ndk native_activity.h
2013-03-12 15:25 1731#ifndef ANDROID_NATIVE_ACTIVITY ... -
android ndk obb.h
2013-03-12 15:14 1101#ifndef ANDROID_OBB_H #define A ... -
Android NDK APIs
2013-03-12 14:53 947使用 Android NDK 的一般方法: 1、假如想要使用f ...
相关推荐
今天手把手教大家用CSS3制作圆形滚动进度条动画,想不会都难!那么,到底是什么东东呢?先不急,之前我分享了一个css实现进度条效果的博客《CSS实现进度条和订单进度条》,但是呢,那篇博客只是制作出来效果而已,...
自定义圆形进度条,可进行自主设置属性和颜色等;
参考博文,请查看http://blog.csdn.net/harryweasley/article/details/50164995 水波滚动,圆环进度条
AndroidLabelView图片右上角的角标图片以及滚动数字效果以及圆形进度条
最近这两天一直在为大家分享一些HTML5、CSS和SVG的炫酷动画,...这次我们来介绍一款实用的jQuery进度条插件,这款jQuery进度条插件的外观利用了CSS3的特性,让进度条外观显得非常时尚漂亮,一共有10种样式,非常实用。
SVG+CSS3圆形倒计时滚动条动画效果,采用canvas技术进行实现
一个自定义的圆形进度条,中间显示进度,外部根据进度有圆环滚动效果。
Knob是一款通过html5和jquery制作的圆形进度条插件。它的特点是通过鼠标的点击或滚动鼠标轮来控制进度条的增长和减小。这个插件更像是一个仪表盘。
效果描述: 一个简单易用的SVG动画,圆形倒计时效果 使用方法: 1、将style.css样式引入到网页中 2、将body中的代码部分拷贝到你需要的地方即可 (适当调整CSS样式以达到你想要的)
RoundSlider 圆形滑动条 圆形进度条 圆形滚动条,带刻度,滑块,可拓展为滚动条和进度条
在网上翻阅了很多关于ProgressBar滚动效果,但是始终没有找到适合项目中的这种效果,故自己写这篇文章,记录一下写作过程,给大家做一个参考。先看下最终效果效果图 我这里用的是LICEcap软件录制的gif图,效果有点...
QmlCircularProgress: Qml圆形进度条 QmlFontList: Qml获取字体列表 QmlFlipImage: Qml翻转效果 QmlGrayImage: Qml图片转灰度 QmlProgress: Qml进度条 QmlWinExtras: QmlWinExtras QmlCalendar:Qml日历 ...
盯着那绚丽滚动条,忽然觉得,为什么要通过View去写一个滚动条,系统已经提供了ProgressBar以及属于它的特性,我们没必要重新去构建一个,但是系统的又比较丑,不同版本变现还不一定一样。那么得出我们的目标:改变...
这是一款带阅读进度指示的侧边栏列表项UI设计效果...该设计的目的是在用用户滚动鼠标时,在侧边栏列表项中每一个段落标题前都带有一个指示当前段落阅读进度的圆形进度条,使用户可以看到当前的阅读进度,提升用户体验。
进度在滚动时:进度图片逐步显示,背景图片逐步隐藏,达到上面的效果。 4.灵感来自Android控件提供的源码 4.1 默认带进度的进度条,如下图 <ProgressBar android:id=@+id/progressBar2 style=@android:style/...
androd自定义有进度的圆形进度条.zip Android 4.0风格中文滚动输入.zip Android Form EditText 验证输入合法性的编辑框.zip Android 自定义头部控件,简单易用.rar android-gif-drawable 支持fig显示的view.zip ...
jQuery圆形统计插件 README.md roundabout slider1.2 word 仪表盘.html 仿淘宝轮播(无缝做不出来) 仿苹果导航菜单 切换(给未来元素添加事件) 列表项滚动(多用于新闻条目) 加入购物车 动感十足的jquery导航 图片墙 ...
demo此文件夹为从网上凑集到的各类型demo,对于一些基本的项目可能有一些帮助圆形进度条有时候 进度条会以异性方式出现,而圆形可能是出现频率比较多的滚动新闻播放定时3秒滚动新闻,但是现在是再一条内容区间内滚动...