XML-LAYOUT-WISE
seekbar_progress.xml を /res/drawable/ フォルダー内に配置します。
<?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
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/seekbar_background"
android:dither="true"
/>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:startColor="#80028ac8"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:angle="270"
/>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg"
/>
</layer-list>
シークバー
<SeekBar
android:id="@+id/frequency_slider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="20"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/seek_thumb"
/>
プログラムによる
// ------------ custom seekbar
LayerDrawable layer = (LayerDrawable) verticalSeekBar_1.getProgressDrawable();
Drawable draw1 = (Drawable)layer.findDrawableByLayerId(android.R.id.progress);
Bitmap bitmap1 = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.scroll_on);
draw1 = new ClipDrawable(new BitmapDrawable(bitmap1), Gravity.AXIS_PULL_BEFORE, ClipDrawable.HORIZONTAL);
layer.setDrawableByLayerId(android.R.id.progress, draw1);
Drawable draw2 = (Drawable) layer.findDrawableByLayerId(android.R.id.background);
Bitmap bitmap2 = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.scroll_off);
draw2 = new BitmapDrawable(bitmap2);
layer.setDrawableByLayerId(android.R.id.background, draw2);