0
将其标记为重复之前,请完整阅读。这不是关于在android中使用文本创建另一个进度条。我希望进度条大小是动态的以覆盖文本大小。其他解决方案在一个巨大的进度条中间放置了一个小文本。这应该稍微覆盖它。椭圆ProgressBar紧缩文本
我正在尝试在中心创建一个带有textview的椭圆形进度条。我想要整个进度条来封装文本。所以它的宽度和高度不应该是恒定的。相反,它应该比textview略大。我试图在相对布局中封装progressbar和textview(width/height:wrap_content)。我尝试使用textview加上一些负填充对齐textbar的左/右/下/顶部,但我裁剪椭圆形进度条。这里是布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressbar0"
android:layout_alignLeft="@id/txtCategoryTitle"
android:layout_alignRight="@id/txtCategoryTitle"
android:paddingLeft="-50dp"
android:paddingRight="-50dp"
android:layout_alignTop="@id/txtCategoryTitle"
android:layout_alignBottom="@id/txtCategoryTitle"
android:paddingTop="-50dp"
android:paddingBottom="-50dp"
android:indeterminate="false"
android:progressDrawable="@drawable/circle"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="65"
android:layout_below="@id/clickBtn"
android:layout_centerInParent="true"
>
</ProgressBar>
<TextView
android:id="@+id/txtCategoryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text="MY CUSTOM TEXT"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:elevation="5dp"/>
</RelativeLayout>
此外,我愿意提供更好/更简单的方法来做到这一点。