1.制作好相应的图片,放入res/drawable-xxxx文件夹下
2、在 /res/drawable/ 下新建两个文件:seek_img.xml thumb.xml
2、在 /res/drawable/ 下新建两个文件:seek_img.xml thumb.xml
seek_img.xml
<?xml version="1.0" encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android"><!-- 背景图 --><itemandroid:id="@+android:id/background"android:drawable="@drawable/total"/><!--全部能量图 --><itemandroid:id="@+android:id/SecondaryProgress"android:drawable="@drawable/total"/><!-- 进和能量图 --><itemandroid:id="@+android:id/progress"android:drawable="@drawable/part"/></layer-list>
thumb.xml
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><!-- 按下状态 --><itemandroid:state_pressed="true"android:state_focused="true"android:drawable="@drawable/point"/><!-- 普通无焦点状态 --><itemandroid:state_focused="false"android:state_pressed="false"android:drawable="@drawable/point"/></selector>
3、定义好上面两个xml后,就可以在 /res/layout/main.xml中调用它们了。
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><SeekBarandroid:id="@+id/sBar"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_centerInParent="true"android:minHeight="5dip"android:maxHeight="5dip"android:progressDrawable="@drawable/seek_img"android:thumb="@drawable/thumb"/></LinearLayout>