android进度条样式

来源:互联网 发布:视频剪辑用什么软件 编辑:程序博客网 时间:2024/05/08 02:06

1.水平进度条

 (1)水平样式一(progress_horizontal.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="6dip" />            <gradient                android:angle="270"                android:centerColor="#b4b4b4"                android:centerY="0.2"                android:endColor="#000000"                android:startColor="#000000" />        </shape>    </item>    <item android:id="@android:id/secondaryProgress">        <clip>            <shape>                <corners android:radius="6dip" />                <gradient                    android:angle="270"                    android:centerColor="#b4b4b4"                    android:centerY="0.2"                    android:endColor="#000000"                    android:startColor="#000000" />            </shape>        </clip>    </item>    <item android:id="@android:id/progress">        <clip>            <shape>                <corners android:radius="6dip" />                <gradient                    android:angle="270"                    android:centerColor="#0070de"                    android:centerY="0.2"                    android:endColor="#0060ce"                    android:startColor="#0185f2" />            </shape>        </clip>    </item></layer-list>

 (2)水平样式二(progress_horizontal_ninpatch.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">        <nine-patch android:src="@drawable/seekbar_n" />    </item>    <item android:id="@android:id/progress">        <clip>            <nine-patch android:src="@drawable/seekbar_d" />        </clip>    </item></layer-list>

 (3)在activity_main.xml中引用

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <SeekBar        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginLeft="65dip"        android:layout_marginRight="65dip"        android:layout_marginTop="85dip"        android:max="100"        android:maxHeight="45dp"        android:minHeight="45dp"        android:progress="50"        android:progressDrawable="@drawable/progress_horizontal_ninpath"        android:thumb="@drawable/seekbar_thumb"        android:thumbOffset="0dp" />    <SeekBar        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginLeft="65dip"        android:layout_marginRight="65dip"        android:layout_marginTop="45dip"        android:max="100"        android:maxHeight="10dp"        android:minHeight="10dp"        android:progress="50"        android:progressDrawable="@drawable/progress_horizontal"        android:thumb="@drawable/seekbar_thumb"        android:thumbOffset="0dp" /></LinearLayout>





0 0