Android 进度条
程序员文章站
2022-03-27 21:49:33
1.直接上代码
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