android中自定义ProgressBar水平样式

来源:互联网 发布:机房网络性能 编辑:程序博客网 时间:2024/05/29 19:03

progressBar 配置如下

  <ProgressBar                android:id="@+id/qr_pro_pro"                style="?android:attr/progressBarStyleHorizontal"                android:layout_width="match_parent"                android:layout_height="5dp"                android:layout_marginLeft="15dp"                android:layout_marginRight="15dp"                android:layout_marginTop="22dp"                android:max="100"                android:progressDrawable="@drawable/qr_pro" />


自定义drawable

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item        android:id="@android:id/background"        android:drawable="@drawable/saomakaisuo_jindutiao_n"></item>    <item android:id="@android:id/progress">        <clip>            <bitmap android:src="@drawable/saomakaisuo_jindutiao_y"></bitmap>        </clip>    </item></layer-list>

注意

参考一下 系统默认 设置

android:progressDrawable="@android:drawable/progress_horizontal"
<?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="5dip" />            <gradient                    android:startColor="#ff9d9e9d"                    android:centerColor="#ff5a5d5a"                    android:centerY="0.75"                    android:endColor="#ff747674"                    android:angle="270"            />        </shape>    </item>        <item android:id="@android:id/secondaryProgress">        <clip>---------------------------------------------------------------------------注意            <shape>                <corners android:radius="5dip" />                <gradient                        android:startColor="#80ffd300"                        android:centerColor="#80ffb600"                        android:centerY="0.75"                        android:endColor="#a0ffcb00"                        android:angle="270"                />            </shape>        </clip>    </item>        <item android:id="@android:id/progress">        <clip>--------------------------------------------------------------------注意            <shape>                <corners android:radius="5dip" />                <gradient                        android:startColor="#ffffd300"                        android:centerColor="#ffffb600"                        android:centerY="0.75"                        android:endColor="#ffffcb00"                        android:angle="270"                />            </shape>        </clip>    </item>    </layer-list>

没有进度值 的  系统设置

android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
<animation-list        xmlns:android="http://schemas.android.com/apk/res/android"        android:oneshot="false">    <item android:drawable="@drawable/progressbar_indeterminate1" android:duration="200" />    <item android:drawable="@drawable/progressbar_indeterminate2" android:duration="200" />    <item android:drawable="@drawable/progressbar_indeterminate3" android:duration="200" /></animation-list>



0 0