android 第三方圆弧进度条,android 可配置的圆弧进度条
Arc ProgressBar Configurable 圓弧環形進度條
DEMO
Attributes
name
format
description
borderWidth
integer
圓弧邊框的寬度
progressStyle
tick/arc
進度條類型,tick 為帶刻度的
radius
integer
半徑
arcbgColor
color
圓弧的邊框背景
degree
integer
弧度,設置為 0 即為圓形進度條,180 為半圓
tickWidth
integer
刻度的寬度
tickDensity
integer
刻度的密度 2~8 越小越密
bgShow
boolean
是否顯示圓弧邊框背景
arcCapRound
boolean
圓弧的筆觸是否為圓形,tick 無效
interface
提供了繪制圓弧中間區域的一個接口
/**
*
* @param canvas
* @param rectF 圓弧的 Rect
* @param x 圓弧的中心 x
* @param y 圓弧的中心 y
* @param storkeWidth 圓弧的邊框寬度
* @param progress 當前進度
*/
public interface OnCenterDraw {
public void draw(Canvas canvas, RectF rectF, float x, float y,float storkeWidth,int progress);
}
默認提供了兩個實現?onImageCenter
OnTextCenter
Use
android:id="@+id/myProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:degree="0"
app:progressStyle="arc" />
android:id="@+id/myProgress01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/myProgress"
app:radius="80dp"
app:progressColor="@color/progressColor"
app:tickDensity="3" />
android:id="@+id/myProgress02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/myProgress"
app:radius="90dp"
app:arcCapRound="true"
app:degree="180"
app:progressStyle="arc"
app:progressColor="@color/progressColorBlue"
app:tickDensity="3" />
mProgress.setOnCenterDraw(new ArcProgress.OnCenterDraw() {
@Override
public void draw(Canvas canvas, RectF rectF, float x, float y, float storkeWidth,int progress) {
Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint.setStrokeWidth(35);
textPaint.setColor(getResources().getColor(R.color.textColor));
String progressStr = String.valueOf(progress+"%");
float textX = x-(textPaint.measureText(progressStr)/2);
float textY = y-((textPaint.descent()+textPaint.ascent())/2);
canvas.drawText(progressStr,textX,textY,textPaint);
}
});
Including in your project
dependencies {
compile 'com.czp.arcProgressBar:ArcProgressBar:1.0.1'
}
總結
以上是生活随笔為你收集整理的android 第三方圆弧进度条,android 可配置的圆弧进度条的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iPhone14如何添加多个睡眠闹钟
- 下一篇: Android接入热敏打印机,Andro