2016-04-27 91 views
1

我想与风格微调创建自定义进度如下:的android:自定义进度栏

enter image description here

我曾尝试以下的方法来实现这一目标:

layout.xml

<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