【问题标题】:How to create a custom determinate circular progress dialog with drawable appended to front of progress drawable?如何创建一个自定义确定的圆形进度对话框,其中可绘制附加到进度可绘制的前面?
【发布时间】:2019-11-20 22:07:57
【问题描述】:
【问题讨论】:
标签:
android
android-layout
android-xml
android-progressbar
【解决方案1】:
对于带有拇指的进度条,您可以使用SeekArc。请参考以下链接SeekArc
https://github.com/neild001/SeekArc
如果您只需要没有拇指的自定义进度条,那么您可以使用以下代码。
使用下面的代码,您可以创建没有拇指的自定义圆形进度条:
在布局文件中:
<ProgressBar
android:layout_width="300dp"
android:layout_height="300dp"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/custom_progressbar"
android:background="@drawable/custom_progressbar"
android:max="100"
android:progress="70"
android:rotation="180"
android:layout_centerInParent="true"/>
在可绘制文件中:custom_progressbar.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thickness="2dp"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
<gradient
android:angle="0"
android:endColor="@android:color/white"
android:startColor="@android:color/white"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
上述代码的输出是: