当前位置: 移动技术网 > 移动技术>移动开发>Android > Android 进度条

Android 进度条

2020年11月12日  | 移动技术网移动技术  | 我要评论
1.直接上代码<ProgressBar android:paddingVertical="3dp" android:layout_alignTop="@+id/item_tv_right" android:layout_marginLeft="13dp" android:layout_toRightOf="@+id/item_img_seckill" android:layou

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.效果图

 

 

 

本文地址:https://blog.csdn.net/qq_15059163/article/details/109645747

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网