I want to customize seekbar in android.
Can anybody guide me how it can be done? I am new to android.
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="34dip"
android:progressDrawable="@drawable/strip"
android:thumb="@drawable/icon_small"
android:layout_weight="3.0" />
You can simply set progressDrawble,thumb and backgroung attribute and you will get all you want.
// ------------ 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);
// --------------
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With