Android横向进度条?

you*_*san 12 android progress-bar

我想实现这样的进度条

在此输入图像描述

请帮助我该怎么做或有图书馆

MSA*_*MSA 32

我看到很多人都在看这篇文章所以我认为我应该编辑它并分享一个例子:

注意(这个例子不完整,它仍在进行中,但我想这是一个起点)

GitHub:Github示例

在此输入图像描述

此示例中的重要部分如下:在drawable中创建一个xml文件custom_progress_bar_horizo​​ntal.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>
            <padding
                android:bottom="3dip"
                android:top="3dip"
                android:left="3dip"
                android:right="3dip"/>
            <corners
                android:radius="5dip" />
            <gradient
                android:startColor="#2a2b2f"
                android:centerColor="#2a2b2f"
                android:centerY="0.50"
                android:endColor="#2a2b2f"
                android:angle="270" />
        </shape>
    </item>
    <item
        android:id="@android:id/progress">
        <clip>
            <shape>
                <corners
                    android:radius="5dip" />
                <gradient
                    android:startColor="#ff0e75af"
                    android:endColor="#ff1997e1"
                    android:angle="90" />
            </shape>
        </clip>
    </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

在styles.xml中添加以下代码

<style name="CustomProgressBar" parent="android:Widget.ProgressBar.Horizontal">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@drawable/custom_progress_bar_horizontal</item>
    <item name="android:minHeight">10dip</item>
    <item name="android:maxHeight">20dip</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在活动布局中添加样式后添加:

    <ProgressBar
        android:id="@+id/customProgress"
        style="@style/CustomProgressBar"
        android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

在框架中显示的进度显然有点棘手,因为您需要扩展ProgressBar类并在那里进行更改.

我将在这里留下一些示例,并在我将其添加到我的github项目时通知.

很棒的例子,如果你想以你的方式取消进展: NumberProgressBar

其他进度条示例:

自定义进度条1

自定义进度条2

自定义进度条3

更新:

同时检查DiscreteSeekBar这是一个很棒的github项目.

Gradle:编译'org.adw.library:discrete-seekbar:1.0.1'

干杯,

  • 我搜索了这个主题并得到了这篇文章.:) (4认同)