How to use CircularCounter to realize the effect of double-layer prototype progress bar
This article mainly introduces how to use CircularCounter to achieve double-layer prototype progress bar effect, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
CircularCounter double-layer prototype progress bar effect
CircularCounter double-layer prototype progress bar, which increases or decreases according to the change of data, supports reverse rotation.
This project is mainly realized by CircularCounter custom control, CircularCounter extends View
It is mainly drawn by the following code:
@ Override
Protected void onDraw (Canvas canvas) {
Super.onDraw (canvas)
Canvas.drawCircle (mBackgroundCenter, mBackgroundCenter
MBackgroundRadius, mBackgroundPaint)
Canvas.drawArc (mOneBounds, START_DEGREES, mOneDegrees, false, mOnePaint)
Canvas.drawArc (mTwoBounds, START_DEGREES, mTwoDegrees, false, mTwoPaint)
Canvas.drawArc (mThreeBounds, START_DEGREES, mThreeDegrees, false
MThreePaint)
Canvas.drawText (Integer.toString (mOneValue), mOneBounds.centerX ()
MTextPosY, mTextPaint)
Canvas.drawText (mMetricText, mOneBounds.centerX (), mMetricPosY
MMetricPaint)
}
Progress value change setting:
/ *
* Setters
*
, /
/ * *
* Set the next values to be drawn
* @ param v1
* @ param v2
* @ param v3
, /
Public void setValues (int v1, int v2, int v3) {
If (v1