QMUIProgressBar
A control progress bar displayed by the progress of the color change, and a rectangular annular support two forms, the main features are as follows:
1. Support displays the progress, support modified text color and size of the progress bar in the form of text.
2. xml attribute modification can progress of the background color, the color of the current progress, the size of the progress bar.
3. Support maximum limit progress.
use
1, the layout initialization
<com.qmuiteam.qmui.widget.QMUIProgressBar
android:layout_marginTop="30dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topbar"
android:id="@+id/rectProgressBar"
android:layout_width="match_parent"
android:layout_height="24dp"
android:textColor="@color/qmui_config_color_white"
android:textSize="16sp"
app:qmui_background_color="@color/qmui_config_color_gray_8"
app:qmui_progress_color="@color/blue"
app:qmui_type="type_rect"/>
<!-- 圆形ProgressBar app:qmui_type="type_circle"-->
<com.qmuiteam.qmui.widget.QMUIProgressBar
app:layout_goneMarginTop="30dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rectProgressBar"
android:id="@+id/circleProgressBar"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_marginTop="30dp"
android:textColor="?attr/qmui_config_color_gray_4"
android:textSize="22sp"
app:qmui_background_color="?attr/qmui_config_color_gray_8"
app:qmui_progress_color="@color/blue"
app:qmui_stroke_width="18dp"
app:qmui_type="type_circle"/>
2, the specific methods
QMUIProgressBar rectProgressBar=findViewById(R.id.rectProgressBar);
QMUIProgressBar circleProgressBar=findViewById(R.id.circleProgressBar);
//设置文字样式 百分之样式 如 10%
circleProgressBar.setQMUIProgressBarTextGenerator(new QMUIProgressBar.QMUIProgressBarTextGenerator() {
@Override
public String generateText(QMUIProgressBar progressBar, int value, int maxValue) {
return 100 * value / maxValue + "%";
}
});
//设置文字样式 分数样式 如 10/100
rectProgressBar.setQMUIProgressBarTextGenerator(new QMUIProgressBar.QMUIProgressBarTextGenerator() {
@Override
public String generateText(QMUIProgressBar progressBar, int value, int maxValue) {
return value + "/" + maxValue;
}
});
//设置方法,最大值
rectProgressBar.setMaxValue(100);
circleProgressBar.setMaxValue(100);
//当前值
rectProgressBar.setProgress(0);
circleProgressBar.setProgress(0);
Figure
Reproduced in: https: //www.jianshu.com/p/b4c2be6da0e2