Android 进度条

1.直接上代码

<ProgressBar
            android:paddingVertical="3dp"
            android:layout_alignTop="@+id/item_tv_right"
            android:layout_marginLeft="13dp"
            android:layout_toRightOf="@+id/item_img_seckill"
            android:layout_below="@+id/item_tv_title"
            android:id="@+id/progressBar"
            style="@style/ProgressBar_Scale"
            android:layout_toLeftOf="@+id/item_tv_right"
            android:layout_alignBottom="@+id/item_tv_right"
            android:layout_width="match_parent"
            android:layout_height="10dp"
            android:progress="50"/>

2.style样式

  //秒杀抢购进度条
    <style name="ProgressBar_Scale" parent="@android:style/Widget.ProgressBar.Horizontal">
        <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
        <item name="android:progressDrawable">@drawable/progress_scale</item>
    </style>

3.边框  progress_scale

<?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>
            <stroke android:width="1dp" android:color="#EF574C"/>
            <corners android:radius="20dip" />

        </shape>
    </item>

    <item android:id="@android:id/progress">
        <scale android:scaleWidth="100%">
            <shape>
                <corners android:radius="20dip" />
                <solid android:color="#F9AAA5" />
                <stroke android:width="2dp" android:color="#00000000"/>
            </shape>
        </scale>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <scale android:scaleWidth="100%">
            <shape>
                <corners android:radius="20dip" />
                <solid android:color="#EF574C" />
            </shape>
        </scale>
    </item>
</layer-list>

4.代码直接调用

progressBar.setProgress(Integer.parseInt(split[0]));

5.效果图

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值