【问题标题】:How can i design semi circle progress bar in android?我如何在android中设计半圆形进度条?
【发布时间】:2016-04-11 10:46:25
【问题描述】:

我需要在 android 中设计以下类型的设计。我如何在android中设计半圆形设计

enter image description here

【问题讨论】:

标签: android progress-bar android-progressbar


【解决方案1】:

像这样定义ProgressBar

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:max="200"
    android:progress="0"
    android:progressDrawable="@drawable/circular" />

创建可绘制对象:

circular(API 级别

<shape
   android:innerRadiusRatio="2.3"
   android:shape="ring"
   android:thickness="5sp" >
   <solid android:color="@color/someColor" />
</shape>

circular(API 级别 >= 21):

<shape
   android:useLevel="true"
   android:innerRadiusRatio="2.3"
   android:shape="ring"
   android:thickness="5sp" >
   <solid android:color="@color/someColor" />
</shape>

useLevel 在 API 级别 21 中默认为 false

既然我们已经设置了max = 200,为了实现半圆,进度的范围应该是0100。您可以使用这些值来获得所需的形状。

因此像这样使用它:

ProgressBar progressBar = (Progressbar) view.findViewById(R.id.progressBar);
progressBar.setProgress(value); // 0 <= value <= 100

【讨论】:

  • 感谢您的回复。但我认为这是进度条形状,但我需要在 xml 文件中进行。你看到我上传的图片了吗?
【解决方案2】:

查看这个库,它可能会对你有所帮助:

https://github.com/glomadrian/velocimeter-view.git

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 2018-01-25
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    相关资源
    最近更新 更多