Android SeekBar thumb Customization

24,321

Solution 1

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

Solution 2

  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);
Share:
24,321
Ahmed Abdullah Saeed
Author by

Ahmed Abdullah Saeed

I am a Senior Software Engineer and Entrepreneur with 6+ years’ experience. I have worked in the following well established companies and startups: Smartlink, LetsHelp, Contrive Solutions and Codehoppers. I have has delivered projects for the following international clients, spanning USA, Europe, KSA and Asia; SAMA KSA, Yesser KSA, France/Orange Telecom France, Athenasys France, Aus-Visa Migration Australia, Clear Soft Russia, Marengo Knoll USA, Blackbird Belgium, Simplicity4Business UK, Kalfany Süße Werbung GmbH Germany, Transparent Hands and Radio Score Pakistan.

Updated on July 20, 2022

Comments

  • Ahmed Abdullah Saeed
    Ahmed Abdullah Saeed almost 2 years

    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.