2016-04-27 7 views
1

私は以下のようなスタイルスピンナーでカスタムプログレスバーを作成したい:アンドロイド:カスタムプログレスバー

layout.xml

:私はこれを達成するために以下の方法を試してみました

enter image description here

<ProgressBar 
     android:id="@+id/pb_capture_video" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_centerInParent="true" 
     android:indeterminate="false" 
     android:max="60" 
     android:indeterminateDrawable="@drawable/layer_list_progress_bar_background" 
     android:progress="30" 
     android:progressDrawable="@drawable/layer_list_progress_bar_foreground"/> 

layer_list_progress_bar_background.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/background"> 
    <shape android:shape="oval"> 
     <stroke 
      android:width="1dp" 
      android:color="@android:color/white" /> 
    </shape> 
</item> 

layer_list_progress_bar_foreground.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/progress"> 
    <shape android:shape="oval"> 
     <stroke 
      android:width="1dp" 
      android:color="@color/colorAccent" /> 
    </shape> 
</item> 

しかし、私はできないの進行状況を表示します。私のコードの出力は以下の通りです:

enter image description here

私はどこか間違っていますか?とにかく私は私が欲しいものを達成することができますか?

これが正しい方法でないと思われる場合は、私に別のものを教えてください。

+0

[This](https://github.com/natasam/DemoProgressViewsLibApp)が便利かもしれません。 –

答えて

0

あなたはそれほど簡単ではないと思います。あなたはJavaでアニメーションを利用する必要があります。ここにはsolutionがあります。