Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing seekbar in android

Tags:

android

I want to customize seekbar in android.

enter image description here

Can anybody guide me how it can be done? I am new to android.

like image 634
Ajn Avatar asked Jun 04 '11 11:06

Ajn


2 Answers

<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.

like image 63
βhargavḯ Avatar answered Sep 23 '22 03:09

βhargavḯ


// ------------ 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);

// --------------
like image 30
Nayanesh Gupte Avatar answered Sep 23 '22 03:09

Nayanesh Gupte