Android的水平进度条? [英] Android horizontal progress bar?

查看:213
本文介绍了Android的水平进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现这样一个进度条

I'd like to implement a progress bar like this

请帮我该怎么做,或是否有一个库

Please help how can I do it or if there is a library

推荐答案

我看到很多人都在寻找对这个职位,所以我想我应该编辑和分享一个例子:

I saw that a lot of people are looking on this post so I thought that I should edit it and share an example:

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

Note (this example is not complete, it's still in progress but I guess it's a starting point)

GitHub上: Github上例

在这个例子中的重要部分是如下: 在创建绘制一个XML文件custom_progress_bar_horizo​​ntal.xml并添加下面的内容。

The important part in this example is below: Create in drawable a xml file custom_progress_bar_horizontal.xml and add the content below.

<?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>

添加以下code在styles.xml

Add the following code in 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>

在您添加的风格在你的活动布局地址:

After you have added the style in your activity layout add:

    <ProgressBar
        android:id="@+id/customProgress"
        style="@style/CustomProgressBar"
        android:layout_width="match_parent"/>

在一个框架dispaly下面的进步这是一个有点棘手,因为你需要扩展ProgressBar类并进行更改那里。

The progress dispaly below in a frame it's a little tricky because you need to extend the ProgressBar class and make the changes there.

我会离开这里的一些例子,并通知时,我将增加他们在我的github上的项目。

I will leave here some examples and notify when I will add them in my github project.

很好的例子,如果你想disaply在你途中的进展: NumberProgressBar

Great example if you want to disaply the progress in your way: NumberProgressBar

其他的进度条的例子:

自定义进度酒吧1

自定义进度条2

自定义进度条3

干杯,

这篇关于Android的水平进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆