1 横向进度条
<ProgressBarstyle="@android:style/Widget.ProgressBar.Horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:max="100"android:secondaryProgress="60"android:progress="55"android:progressDrawable="@drawable/horizontal_progress_drawable_red" />
horizontal_progress_drawable_red.xml
<?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="5px"></corners><solid android:color="@color/redStart"/></shape></item><item android:id="@android:id/secondaryProgress"><clip><shape><corners android:radius="2px"></corners><solid android:color="@color/blueEnd"/></shape></clip></item><item android:id="@android:id/progress"><clip><shape><corners android:radius="2px"></corners><solid android:color="@color/blueEnd"/></shape></clip></item></layer-list>
2 圆形进度条 和第一种是一样的。可以自己控制。
<ProgressBarandroid:id="@+id/progress_bar_h"style="?android:attr/progressBarStyleHorizontal"android:layout_width="500px"android:layout_height="500px"android:layout_gravity="center"android:layout_marginTop="28px"android:progressDrawable="@drawable/round_pg_style"android:max="100"android:progress="1" />
round_pg_style.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@android:id/background"><shapeandroid:innerRadiusRatio="3.5"android:shape="ring"android:useLevel="false"android:type="sweep"android:thicknessRatio="25.0"><solid android:color="@color/dian_color"/></shape></item><item android:id="@android:id/progress"><rotateandroid:pivotX="50%"android:pivotY="50%"android:fromDegrees="-90"android:toDegrees="-90"><shapeandroid:innerRadiusRatio="3.5"android:shape="ring"android:angle="0"android:type="sweep"android:thicknessRatio="25.0"><solid android:color="#44aa00"/></shape></rotate></item>
</layer-list>
3 转圈进度条 ,不确定时间
<ProgressBarandroid:id="@+id/progressBar"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="50px" />
4 下载文件,横向进度条 代码
ProgressDialog progress = new ProgressDialog(context);progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);progress.setTitle("");progress.setMessage("下载中");progress.setIndeterminate(false);//设置为fase等待进度更新,设置为true则左右循环滚动progress.setMax(100);progress.setCancelable(false);progress.show();在ui里面更新progress.setProgress(msg.arg1);