close
First, you should set SeekBar XML :
<SeekBar
.
.
android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/thumb_style"
.
.
/>
Second, set seekbar_style like this (Use .PNG image)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:drawable="@drawable/seekbar_bg" />
<item android:id="@android:id/secondaryProgress">
<clip android:drawable="@drawable/seekbar_sp" />
</item>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seekbar_fp" />
</item>
</layer-list>
and you can set seekbar_style another xml description like this:
<?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="15dip" />
<gradient
android:startColor="#ffa9a9a9"
android:centerColor="#ffe8e8e8"
android:centerY="0.75"
android:endColor="#ffd1d1d1"
android:angle="270"
/>
</shape>
</item>
<item android:id = "@android:id/secondaryProgress" >
<clip >
<shape >
<corners android:radius = "15dip" />
<gradient
android:startColor = "#ffb2cfef"
android:centerColor = "#ffd1deef"
android:centerY = "0.75"
android:endColor = "#ff446fb7"
android:angle = "270"
/>
</shape >
</clip >
</item >
<item android:id = "@android:id/progress" >
<clip >
<shape >
<corners android:radius = "15dip" />
<gradient
android:startColor = "#ff4990cc"
android:centerColor = "#ff77acea"
android:centerY = "0.75"
android:endColor = "#ff3862ab"
android:angle = "270"
/>
</shape >
</clip >
</item >
</layer-list>
Final thumb is (use png)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/thumb" />
</selector>
and another method set thumb is
<? xml version = "1.0" encoding = "UTF-8" ?>
< selector xmlns:android = "http://schemas.android.com/apk/res/android" >
<!--pressed-->
< item
android:state_focused = "true"
android:state_pressed = "true"
android:drawable = "@drawable/thumb_pressed" />
<!--normal-->
< item
android:state_focused = "false"
android:state_pressed = "false"
android:drawable = "@drawable/thumb_normal" />
<!--focused-->
< item
android:state_focused = "true"
android:state_pressed = "false"
android:drawable = "@drawable/thumb_focused" />
</ selector >
全站熱搜