进度条指示


这里写图片描述

首先是布局文件

<FrameLayout
    android:layout_width="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_height="wrap_content">

    <ProgressBar
        android:id="@+id/pb_process"
        style="@style/ProgressStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:indeterminate="false" />

    <TextView
        android:id="@+id/tv_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="@color/white"/>

</FrameLayout>

添加style-ProgressStyle

<style name="TrainProgressStyle" parent="@android:style/Widget.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/my_progress</item>
</style>

添加drawable-my_progress

<?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>
            <corners android:radius="5dip" />
            <gradient
                android:angle="270"

                android:centerY="0.75"
                android:endColor="@color/gray_BB"
                android:startColor="@color/gray_BB" />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="270"
                    android:centerColor="#f69200"
                    android:centerY="0.75"
                    android:endColor="#ff9800"
                    android:startColor="#ff9800" />
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <level-list>
            <!-- 进度满时 level = 10000-->
            <item
                android:maxLevel="10000"
                android:minLevel="10000">
                <clip>
                    <shape>
                        <corners android:radius="5dip" />
                        <gradient
                            android:angle="270"
                            android:centerColor="#21a837"
                            android:centerY="0.75"
                            android:endColor="#22ac38"
                            android:startColor="#22ac38" />
                    </shape>
                </clip>
            </item>
            <!-- 进度未满时 level < 10000-->
            <item
                android:minLevel="0"
                android:maxLevel="9999"
                >
                <clip>
                    <shape>
                        <corners android:radius="5dip" />
                        <gradient
                            android:angle="270"
                            android:centerColor="#f69200"
                            android:centerY="0.75"
                            android:endColor="#ff9800"
                            android:startColor="#ff9800" />
                    </shape>
                </clip>
            </item>
        </level-list>
    </item>

</layer-list>

activity里的使用和安卓默认的一样

pb_progress.setMax();
pb_progress.setProgress();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值