自定义的seekBar:
1.在res/drawable/下创建自定义背景颜色的文件: progressbar_brightness.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 ><solid android:color="@color/grgray" /><corners android:radius="10dp"/></shape>
</item><!--进度颜色-->
<item android:id="@android:id/progress"><clip><shape><solid android:color="@color/orange" /><corners android:radius="10dp"/></shape></clip>
</item><!--第二进度颜色-->
<item android:id="@android:id/secondaryProgress"><clip><shape ><solid android:color="@color/orange"/><corners android:radius="10dp"/></shape></clip>
</item>
</layer-list>
2.将背景颜色设置到seekBar:
<SeekBarandroid:id="@+id/pb_brightness"android:layout_width="300dp"android:layout_height="wrap_content"android:layout_toLeftOf="@id/btn_brightness_add"style="?android:attr/progressBarStyleHorizontal"android:layout_centerVertical="true"android:thumb="@drawable/thumb_seek_brightness" //按钮图片android:thumbOffset="0dp" // 解决两端空隙android:paddingTop="10dp"android:paddingBottom="10dp"android:minHeight="8dp"android:maxHeight="8dp"android:paddingStart="0dp"android:paddingEnd="0dp"android:max="100"android:progress="50"android:progressDrawable="@drawable/progressbar_brightness" //自定义背景/>
自定义图片的progressBar:
1.布局文件中设置自定义的图片背景:
<ProgressBarandroid:id="@+id/pb_loading"android:layout_width="wrap_content"android:layout_height="wrap_content"style="@android:style/Widget.ProgressBar.Small"android:indeterminateDrawable="@drawable/progress_wifi" //设置自定义进度条的图片/>
2.创建res/drawable/progress_wifi.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" ><item><rotateandroid:drawable="@drawable/loading_bg2"android:fromDegrees="0.0"android:pivotX="50.0%"android:pivotY="50.0%"android:toDegrees="720.0" /><span style="white-space:pre"> </span> <!-- 其中360.0值越大,转的圈圈越快 --></item></layer-list>
3.将自定义的图片放到res/drawable/ 目录下
自定义帧动画的progressBar:
1. <ProgressBarandroid:layout_width="27dp"android:layout_height="10dp"android:indeterminateDrawable="@drawable/loading" //设置帧动画文件 />
2.创建帧动画文件, 放到res/drawable/loading.xml:
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false"><item android:drawable="@drawable/loading00" android:duration="30"/><item android:drawable="@drawable/loading01" android:duration="30"/><item android:drawable="@drawable/loading02" android:duration="30"/><item android:drawable="@drawable/loading03" android:duration="30"/><item android:drawable="@drawable/loading04" android:duration="30"/><item android:drawable="@drawable/loading05" android:duration="30"/><item android:drawable="@drawable/loading06" android:duration="30"/><item android:drawable="@drawable/loading07" android:duration="30"/><item android:drawable="@drawable/loading08" android:duration="30"/><item android:drawable="@drawable/loading09" android:duration="30"/><item android:drawable="@drawable/loading10" android:duration="30"/><item android:drawable="@drawable/loading11" android:duration="30"/><item android:drawable="@drawable/loading12" android:duration="30"/><item android:drawable="@drawable/loading13" android:duration="30"/><item android:drawable="@drawable/loading14" android:duration="30"/><item android:drawable="@drawable/loading15" android:duration="30"/><item android:drawable="@drawable/loading16" android:duration="30"/><item android:drawable="@drawable/loading17" android:duration="30"/><item android:drawable="@drawable/loading18" android:duration="30"/><item android:drawable="@drawable/loading19" android:duration="30"/><item android:drawable="@drawable/loading20" android:duration="30"/><item android:drawable="@drawable/loading21" android:duration="30"/><item android:drawable="@drawable/loading22" android:duration="30"/><item android:drawable="@drawable/loading23" android:duration="30"/><item android:drawable="@drawable/loading24" android:duration="30"/><item android:drawable="@drawable/loading25" android:duration="30"/><item android:drawable="@drawable/loading26" android:duration="30"/><item android:drawable="@drawable/loading27" android:duration="30"/><item android:drawable="@drawable/loading28" android:duration="30"/><item android:drawable="@drawable/loading29" android:duration="30"/> </animation-list>
3.将动画图片素材放到 res/drawable-xhdpi: