【问题标题】:How to make this progress bar in Android? [closed]如何在Android中制作这个进度条? [关闭]
【发布时间】:2017-09-09 07:46:53
【问题描述】:

我想在android中制作这个进度条

【问题讨论】:

标签: android


【解决方案1】:

progressbar创建自定义drawable,并使用属性android:progressDrawable设置自定义drawable

试试这个:

<ProgressBar
    android:id="@+id/ProgressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:indeterminate="false"
    android:maxHeight="14dip"
    android:minHeight="14dip"
    android:progress="75"
    android:progressDrawable="@drawable/custom_progressbar" />

custom_progressbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- background color -->
    <item android:id="@android:id/background">
        <shape>
            <solid android:color="#D9D9D9" />
            <corners android:radius="10dp"/>
        </shape>
    </item>

    <!-- progress color -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid android:color="#F1C40F" />
                <corners android:radius="10dp"/>
            </shape>
        </clip>
    </item>
</layer-list>

输出:

【讨论】:

    【解决方案2】:

    使用原生 ProgressBar 并将可绘制对象设置为其“android:progressDrwable”。 drawable 看起来像这样:

    <!-- background -->
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="4dp" />
            <solid android:color="#000000" />
        </shape>
    </item>
    <!-- progress -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="4dp" />
                <solid android:color="#000000" />
            </shape>
        </clip>
    </item>
    <!-- second progress -->
    <item android:id="@android:idcondaryProgress">
        <clip>
            <shape>
                <corners android:radius="4dp" />
                <solid android:color="#000000" />
            </shape>
        </clip>
    </item>
    

    【讨论】:

    • 错过图层列表
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多