Ahmed Abdullah Saeed
Ahmed Abdullah Saeed

Reputation: 707

Android SeekBar thumb Customization

I want to hide bar and only want to show thumb. I did it with max-height=0dip but it did not completely work. I also want to set text on thumb and create thumb with multiple images. For example thumb which i button like image and has text and this button has tail downword, which increases with row increment.

Upvotes: 5

Views: 25745

Answers (3)

wraithie
wraithie

Reputation: 363

In order to hide the bar, you can set opacity value using hex colors. You just need to add the right prefix. I hid the seekBar using this code:

android:progressBackgroundTint="#00555555"
android:progressTint="#00555555"

Where the first two ciphers (i.e. "00") set opaqueness (alpha percentage) and the other six (i.e. "555555") set the color.

Check this post for more information and a list of hex opacity values: Understanding colors on Android (six characters)

Upvotes: -1

Nayanesh Gupte
Nayanesh Gupte

Reputation: 2775

  SeekBar seekbar = new SeekBar(context, attrs);

     // ------------- custom thumb
            //----- using resources 

    seekbar.setThumb(new BitmapDrawable(BitmapFactory.decodeResource(
         context.getResources(), R.drawable.seekbar_progress_thumb)));
          //----- or using shape drawable


    ShapeDrawable thumb = new ShapeDrawable(new RectShape());
    thumb.getPaint().setColor(Color.rgb(0, 0, 0));
    thumb.setIntrinsicHeight(-80);
    thumb.setIntrinsicWidth(30);
    seekbar.setThumb(thumb);

Upvotes: 2

Arve
Arve

Reputation: 8128

Regarding removing the background, I managed to do this in the following way. Here, the blank drawable is a transparent png of 1x1 pixel

    <SeekBar
        android:id="@+id/bar"
        android:layout_width="fill_parent"
        android:layout_height="30dip"
        android:progressDrawable="@drawable/blank"
     />

You can also change the drawable by using:

android:thumb="@drawable/icon"

To add text, I guess you'll have to create a custom component

Upvotes: 16

Related Questions