系统自带的SeekBar真是太难看了,不能容忍! 只能自己做了,先来张效果图
第1个Seekbar 背景是颜色,thumb是图片,上代码:
<SeekBar
android:id="@+id/sb_detail_play_progress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:paddingLeft="15.0dip"
android:paddingRight="15.0dip"
android:progressDrawable="@drawable/progress_holo_light"
android:thumb="@drawable/detail_icon_schedule_ball" />
drawable/po_seekbar.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="#ff51495e" />
</shape>
</item>
<item android:id="@*android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#ff51495e" />
</shape>
</clip>
</item>
<item android:id="@*android:id/progress">
<clip>
<shape>
<solid android:color="#ff996dfe" />
</shape>
</clip>
</item>
</layer-list>
drawable/seekbar_thumb.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/seekbar_thumb_normal" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />
<item android:drawable="@drawable/seekbar_thumb_normal" />
</selector>
-
改变大小
-
如何改变seekbar的厚度呢,是没有属性能直接修改的,得通过重新定义样式:
-
<SeekBar
-
android:layout_width="match_parent"
-
android:layout_height="wrap_content"
-
android:layout_marginTop="20dp"
-
android:thumb="@drawable/seek"
-
android:progressDrawable="@drawable/seek_style"
-
/>
-
-
<?xml version="1.0" encoding="utf-8"?>
-
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
-
<size
-
android:width="20dp"
-
android:height="20dp"
-
/>
-
<solid android:color="#60f0"/>
-
</shape>
progressDrawable 修改进度条的样式:-
<?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="#999"/>
-
</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>
-
<solid android:color="#600f"/>
-
</shape>
-
</clip>
-
</item>
thumb 修改可拖拽的圆的样式: