Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6721579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:20:47+00:00 2026-05-26T09:20:47+00:00

I am trying to create a seekbar with a thumb that changes color when

  • 0

I am trying to create a seekbar with a thumb that changes color when it is pressed by the user and change back when the user lets go. I managed to change the thumb drawable using set thumb. However, I also had to set the drawable boundries in java to get it to appear after the change. Now when the user lets go of the slider and it reverts to its original drawable it resets the drawable to the zero position and leaves the progress where it should be. I have tried using a global variable to reset the seekbar progress after the drawable is changed, but it doesn’t seems to work. If I use a static integer to reset the progress it works the way I want it to.

Kinda new to android and I don’t know what I am doing wrong.

This is the code that changes the drawable when it is touched.

private void Seek_Height_Click() {
    Drawable myThumb = getResources().getDrawable(R.drawable.slider_button_click);
    myThumb.setBounds(new Rect(0, 0, myThumb.getIntrinsicWidth(),myThumb.getIntrinsicHeight()));
    Height_of_Target_skbr.setThumb(myThumb);
    Height_of_Target_skbr.setThumbOffset(-1);
}

This is the code to set the thumb back to the original drawable.

private void Seek_Height_UnClick() {
    Drawable myThumb = getResources().getDrawable(R.drawable.slider_button);
    myThumb.setBounds(new Rect(0, 0,   myThumb.getIntrinsicWidth(),myThumb.getIntrinsicHeight()));
    Height_of_Target_skbr.setThumb(myThumb);
    Height_of_Target_skbr.setThumbOffset(-1);
    Height_of_Target_skbr.setProgress(Height_Prog_int);
}

This is the code that calls the above method.

this.Height_of_Target_skbr.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            returnHeight_skbr();
            Seek_Height_UnClick();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            returnHeight_skbr();
            Seek_Height_Click();
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            returnHeight_skbr();
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:20:47+00:00Added an answer on May 26, 2026 at 9:20 am

    I was able to make this work using by creating a style in the drawable folder and then setting the thumb drawable to that style.

    I refereed to this tutorial to make this work.
    http://www.youtube.com/watch?v=zXXCFmfJMNw

    Code for Thumb Style

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item 
        android:state_pressed="true"
        android:drawable="@drawable/slider_button_click">
    </item>
    <item 
        android:drawable="@drawable/slider_button">
    </item>
    </selector>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create my first iPhone app that would play back audio. When I
I am trying create a small web application that allows a user to login
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create a user account in a test. But getting a Object reference
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying create a box in my Django app that displays text (and possibly
I'm trying create a ASMX webservice that can perform a HTTP GET request. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.