【问题标题】:android : custom progress barandroid:自定义进度条
【发布时间】:2016-04-27 09:09:32
【问题描述】:

我想创建自定义进度条,样式如下:

我尝试了以下方法来实现这一点:

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>

但是,我无法显示进度。我的代码输出如下:

我在某个地方出错了吗?无论如何我可以实现我想要的吗?

如果这似乎不是正确的方法,请向我推荐其他方法。

【问题讨论】:

  • This 可能有用。

标签: android android-progressbar layer-list


【解决方案1】:

没有你想的那么简单。您必须在 Java 中使用动画。这是solution

【讨论】:

    猜你喜欢
    • 2016-05-06
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    相关资源
    最近更新 更多