Recently, I've been working with seekbar. I want to create seekbar have a small gap between thumb and progress bar like in the picture I attached. Can anyone help me or tell me how I can do. Thanks
Seekbar sample
I think your thumb image have some spacing so this is happend.
I solved this problem by very simple, like Brahgrav said, just redraw the thumb with spaced outside and set to android:thumb. I will attach a thumb image for you to see.
Thumb image
Related
I have a problem with seekbars. They work without issues until I try and do the following:
seekBar.setProgressDrawable(getResources().getDrawable(R.drawable.seek_bar));
I even tried using a color only instead of a drawable resource. Same issue. The problem is when I do set the drawable, I see that the Seekbar drawable is a bit shorter (from start and end) and the thumb icon can go beyond it.
Also, I have noticed that the thumb icon itself has a white background surrounding it (not transparent). I even tried setting a vector drawable for the thumb, and the thumb went beyond the boundaries of seekbar (part of the thumb was hidden).
Could someone explain this behavior. I have tried searching for around three hours now without luck. I even tried the solution from:
How to set Android SeekBar progress drawable programatically
Which has the same issue for me.
Thank you.
To get rid of the non-transparent background I have used:
seekBar.setSplitTrack(false);
To make the thumb not go beyond the boundaries, I have shrunk the thumb. It is not perfect but it works.
I am trying to put an image as thumb for my custom seekbar. The problem is I don't know what should the size of the image for the thumb be. In my case it just goes outside of the seekabr (too big).
Check this, you will get idea about android's standard icon sizes
http://developer.android.com/design/style/iconography.html
Can anyone tell me how I can set the size (height, width) of the thumb in seekbar. I googled and found this to be done only through code. But I want this to set in xml only.
I have a work around for exactly what you need, you just need to use an image and place it in your xml at android:thumb="#drawable/seekbar_thumb_slider"
you can use this thumb as per your choice .
It doesn't exaclty answer your question but you can do it as a workaround, a thinner drawable would reduce the Thumb size ofcourse.
Why the standard seekbar in Android 2.1 or other version looks so odd. I mean the Thumb image begins outside the container. Am I doing something wrong or this is a normal behavior. How to correct this behavior ?
It is the default thumb image. You can set the thumb image of seekbar. create a small image which you like to set as thumb image. using the following code
android:thumb="#drawable/music_player_playerhead"
I have set negative paddings on my custom seekbar so that the round thumb image can go outside the bar, but the thumb isn't rendered out there, is there anyway to force the thumb to be drawn outside those bounds?
Sorry guys, I'm new to Android development, and have been tasked with fixing an existing application. The problem is that we have a custom rounded looking track bar, which consists of two rounded 'end cap' images and a 1 px background that is tiled to create the seekbar. As far as I can tell there was never one image that could be set as the background of a normal SeekBar, which is why a custom one was created.
The thumb is a circle and needs to 'fit' into the end caps - the three pieces of the bar are in a relative layout. Right now I'm kind of unclear as to how the 1 px background png gets stretched as the seekbar bg, otherwise I would try to tack on the two endcaps onto that drawable some how ... ?
Please let me know if this was unclear and I'll try to post any followup info. Thanks in advance for any advice!!
Oh, I'm using Android 2.1 if that's relevant to anyone's interests :)
This is what it looks like when the thumb all the way over - outside of the seekbar. Ideally what I need is for the thumb to be shown as 'inside' the endcap image :-/
I was having the same problem, my thumb is very big length wise and it kept being cut off. Make sure that you set the offset property AFTER you set the drawable for your thumb, like this:
seek.setThumb(Main.app.getResources().getDrawable(R.drawable.thumb));
seek.setThumbOffset(15);
This will set the correct offset when your thumb is very long.
Try to change the thumb offset property, after that it will not go off from the seek bar
I just ran into this issue. I was able to get satisfactory results by using android:paddingLeft and android:paddingRight within the XML.