I want to customise my seekbar as below. And also would want to show the thumb only when the seekbar has focus i.e when user is dragging the seekbar.
Asked
Active
Viewed 159 times
1 Answers
0
You can just hide the thumb in onStopTrackingTouch()
and make it visible in onStartTrackingTouch()
.
final SeekBar seekbar = findViewById(R.id.seekbar);
//Hide the seekbar's thumb.
seekbar.getThumb().setAlpha(0);
final Handler seekBarHandler = new Handler(Looper.getMainLooper());
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(final SeekBar seekbar, final int progress, final boolean feomUser)
{
//Do something...
}
public void onStartTrackingTouch(final SeekBar seekbar)
{
seekBarHandler.removeCallbacksAndMessages(null);
seekbar.getThumb().setAlpha(255);
}
public void onStopTrackingTouch(final SeekBar seekbar)
{
//Hide the thumb if not focus for a second.
seekBarHandler.postDelayed(new Runnable() {
public void run() {
seekbar.getThumb().setAlpha(0);
}
}, 1000L); //Delay
}
});

Darkman
- 2,941
- 2
- 9
- 14
-
Thanks that helped. Any inputs on how I can customise seekbar like in the above image. – NoobAndroidDeveloper Jul 02 '21 at 06:23
-
Look a look at [this post](https://stackoverflow.com/questions/41693154/custom-seekbar-thumb-size-color-and-background). If you're still have a problem, don't hesitate to ask a new question. – Darkman Jul 02 '21 at 06:33