1
进度条XML是:如何绘制如下图所示的圆形进度条?
<ProgressBar
android:id="@+id/progressBarCircular"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignTop="@id/squareView_3"
android:layout_toRightOf="@id/squareView_3"
android:layout_marginTop="-105dp"
android:layout_marginLeft="40dp"
android:indeterminate="false"
android:max="100"
android:progress="0"
android:background="@color/BlackText"
android:progressDrawable="@drawable/circular_progressbar" />
circular_progressbar.xml是:
<?xml version="1.0" encoding="UTF-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/background">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8.0">
<solid android:color="@color/DarkGrey" />
</shape>
</item>
<item android:id="@+id/progress">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="12.0">
<solid android:color="@color/green" />
</shape>
</item>
</layer-list>
和设置进度:
ProgressBar pb = (ProgressBar)view.FindViewById(Resource.Id.progressBarCircular);
pb.Progress = 75;
任何帮助将心怀感激。 Thankyou,快乐编码。
有没有办法设置和更新进度? –
这是您为进度条设置进度的默认方式。我认为可绘制本身没有任何东西。 –
Thankyou @Nigam Patro。你的答案是赖特,但它没有给出进展(绿圈),如图所示,需要调整从和到度。答案中的更新部分给出了精确的外观,如图片中所示。 @ Nishant Verma最初可以在xml中设置进度,但对于实时进度,您需要以编程方式设置ProgressBar的“进度”属性。 Thankyou,快乐编码。 – codemilan