如何实现弧形的进度条或SeekBar
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何实现弧形的进度条或SeekBar相关的知识,希望对你有一定的参考价值。
参考技术A [android UI界面]如何实现弧形的进度条或SeekBar? 转载public MusicSeekbar(Context context, AttributeSet attrs)
super(context, attrs);
mContext = context;
mPaint.setAntiAlias(true);
mPaint.setFilterBitmap(true);
mPaint.setStrokeWidth(4);
mPaint.setColor(getResources().getColor(R.color.music_seekbar));
mPaint.setStyle(Style.STROKE);
mBitmapDot = BitmapFactory.decodeResource(getResources(),
R.drawable.ui_music_dot);
// if(mThread==null)
//
// mThread=new Thread(new myThread());
// mThread.start();
//
mPaintText.setAntiAlias(true);
mPaintText.setStyle(Style.STROKE);
mPaintText.setStrokeWidth(1);
// conn=new MediaPlayerServiceConnection(mContext);
// init();
protected void onDraw(Canvas canvas)
mLeft = (float) (Centre_X - RADIUS
* Math.cos((90 - mSeekBarTotalDegree / 2 + mDegree) / 180
* Math.PI));
mTop = (float) (Centre_Y - RADIUS
* Math.sin((90 - mSeekBarTotalDegree / 2 + mDegree) / 180
* Math.PI));
Shader mLinearGradient = new LinearGradient(mLeft - 80, 100, mLeft,
100, new int[]
getResources().getColor(R.color.music_seekbar),
getResources().getColor(R.color.music_seekbar1) ,
null, Shader.TileMode.CLAMP);
mPaint.setShader(mLinearGradient);
canvas.drawArc(mRect, mStartDegree, mDegree, false, mPaint);
canvas.drawBitmap(mBitmapDot, mLeft - 20, mTop - 20, new Paint());
canvas.save();
canvas.rotate(-22, Centre_X, Centre_Y);
mPaintText.setColor(getResources().getColor(R.color.music_seekbar));
canvas.drawText(formatTime(mCurTime), 150, 0, mPaintText);
canvas.restore();
canvas.save();
canvas.rotate(20, Centre_X, Centre_Y);
mPaintText.setColor(Color.WHITE);
canvas.drawText(formatTime(mDuration), 150, 0, mPaintText);
canvas.restore();
super.onDraw(canvas);
本回答被提问者和网友采纳
winform 实现单击按钮后显示进度条或等待窗口
参考技术A 以datagridview为例子:for(int i=0;i<datagridview.rows.count;i++)
设置progressBar的最大值为datagridview.rows.count;
设置progressBar.Value=i;
参考技术B 做进度条或者等待窗口的时候是需要用多线程的
以上是关于如何实现弧形的进度条或SeekBar的主要内容,如果未能解决你的问题,请参考以下文章
[Android] Android 定时任务实现的三种方法(以SeekBar的进度自动实现为例)