2017-09-25 258 views
1

我正在嘗試創建一個如下圖所示的進度條。我想要的是: 1.我希望能夠以編程方式設置進度值。 2.我希望能夠改變弧的顏色 - 背景(灰色)和前景(綠色)。如何在Android中創建弧形進度條?

我看着圖書館,但沒有發現這種特殊的形狀和​​風格。我沒有足夠的精力來創建自定義drawable來自己創建。任何幫助表示讚賞!

enter image description here

回答

3

除了上面的回答,您還可以使用CircleProgress裏面好像有東西,看起來酷似你的使用情況:

enter image description here

用法:

<com.github.lzyzsd.circleprogress.ArcProgress 
    android:id="@+id/arc_progress" 
    android:background="#214193" 
    android:layout_marginLeft="50dp" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    custom:arc_progress="55" 
    custom:arc_bottom_text="MEMORY"/> 

此外,如果您檢查此庫(自述文件底部)上的許可證,則無論您希望如何使用它,似乎都是非常有利的。

+1

工程就像一個魅力,謝謝! – blackout

2

您可以使用SeekArc。它可以做你需要的一切來獲得結果。

這將是這個樣子

<com.triggertrap.seekarc.SeekArc 
    android:id="@+id/seekArc" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:padding="30dp" 
    seekarc:rotation="180" 
    seekarc:startAngle="30" 
    seekarc:sweepAngle="300" 
    seekarc:arcColor="@color/grey" 
    seekarc:progressColor="@color/green" 
    seekarc:touchInside="true" />