删除无用代码,添加备注
This commit is contained in:
@@ -59,7 +59,6 @@ class CircularProgressView @JvmOverloads constructor(
|
||||
mProgPaint.isDither = true // 设置抖动
|
||||
mProgPaint.strokeWidth = typedArray.getDimension(R.styleable.CircularProgressView_progWidth, 10.0f)
|
||||
mProgPaint.color = typedArray.getColor(R.styleable.CircularProgressView_progColor, Color.BLUE)
|
||||
// mProgPaint.setPathEffect()
|
||||
// 初始化进度圆环渐变色
|
||||
val startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1)
|
||||
val firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1)
|
||||
@@ -81,19 +80,17 @@ class CircularProgressView @JvmOverloads constructor(
|
||||
val mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2
|
||||
mRectF = RectF(mRectL.toFloat(), mRectT.toFloat(), (mRectL + mRectLength).toFloat(),
|
||||
(mRectT + mRectLength).toFloat())
|
||||
// // 设置进度圆环渐变色
|
||||
// mColorArray?.let {
|
||||
//// mProgPaint.shader = LinearGradient(
|
||||
//// 0f, 0f, 0f,
|
||||
//// measuredWidth.toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR)
|
||||
// sweepGradient()
|
||||
// }
|
||||
|
||||
Log.d(TAG, mRectL.toString() + "," + mRectT.toString())
|
||||
Log.d(TAG, mRectF.toString() + "," + "width:" + measuredWidth.toString() + "," + "PaddingLeft:" + getPaddingLeft().toString())
|
||||
Log.d(TAG, "onMeasure:" + mRectF.toString() + "," + "width:" + measuredWidth.toString() + "," + "PaddingLeft:" + getPaddingLeft().toString())
|
||||
}
|
||||
|
||||
//渐变色
|
||||
/**
|
||||
* 渐变色执行方法
|
||||
* sweepGradient扫描渐变,前两个参数为中心坐标
|
||||
* mConvertColorsArray:渐变色数组
|
||||
* position:与渐变数组个数对应的渐变点
|
||||
* Matrix:改变开始渐变的角度,默认3点方向,改为12点方向
|
||||
* */
|
||||
fun sweepGradient() {
|
||||
if (mConvertColorsArray == null) {
|
||||
return
|
||||
@@ -101,8 +98,7 @@ class CircularProgressView @JvmOverloads constructor(
|
||||
val position = FloatArray(2)
|
||||
position[0] = 0.0f;
|
||||
position[1] = mProgress.toFloat() * 0.01f
|
||||
Log.d(TAG, "mProgress" + mProgress.toString())
|
||||
val sweepGradient = SweepGradient((measuredWidth / 2).toFloat(), (measuredHeight/ 2).toFloat(), mConvertColorsArray!!, position)
|
||||
val sweepGradient = SweepGradient((measuredWidth / 2).toFloat(), (measuredHeight / 2).toFloat(), mConvertColorsArray!!, position)
|
||||
val matrix = Matrix()
|
||||
matrix.setRotate(-90F, (measuredWidth / 2).toFloat(), (measuredHeight / 2).toFloat())
|
||||
sweepGradient.setLocalMatrix(matrix);
|
||||
@@ -216,17 +212,8 @@ class CircularProgressView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setProgColor(startColor: Int, endColor: Int) {
|
||||
mConvertColorsArray = intArrayOf(ContextCompat.getColor(context, startColor), ContextCompat.getColor(context, endColor))
|
||||
// mColorArray?.let {
|
||||
// if (mRectF != null) {
|
||||
//// mProgPaint.shader = LinearGradient(0f, 0f, 0f,
|
||||
//// getMeasuredWidth().toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR)
|
||||
// Log.d(TAG, "setProgColor:" + getMeasuredWidth().toString() + "mProgress:" + mProgress.toString())
|
||||
// sweepGradient()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
fun setProgColor(colorArray: IntArray) {
|
||||
|
||||
Reference in New Issue
Block a user