带有文本的Android Progressbar Android [英] Progressbar android with text inside
本文介绍了带有文本的Android Progressbar Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个圆形ProgressBar
,我想在这个圆形条中,用百分比(例如60%或70%..)写进度.
如何在圆形ProgressBar
内执行此操作?
I have a circular ProgressBar
, I want inside this circular bar, write the progression in percentage (like 60 %, or 70 %..)
How can I do this inside the circular ProgressBar
?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBars"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:indeterminate="false"
android:indeterminateDrawable="@drawable/progress_bar"
android:max="100" />
</RelativeLayout>
推荐答案
您可以覆盖ProgressBar
内部的onDraw
并使用Canvas.drawText
决定文本的位置,从而实现覆盖它. 在这里,您可以找到drwawText的文档:
You could achieve it overriding onDraw
inside ProgressBar
, and use Canvas.drawText
to decide where the text should be positioned . Here you can find the documentation for drwawText:
x和y是要绘制的文本的原点的坐标
x and y are the coordinates of the origin of the text being drawn
这篇关于带有文本的Android Progressbar Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文