I have a question about a seekbar.
Everything works perfect, but I have a Problem with the background and the thumb.
I can add a background with a special size of the thumb. If I change the size of the seekbar the background size will change identical to the seekbar size but
the thumb keeps the original size. (I know that I can change the width and the height of the thumb with the attributes.)
Now the question: Is there a way that the thumb changes automatically the size when I change the seekbar size inside the activity_main like the background.
I need this for a special LED Bar.
I hope this pictures will help to understand it
image1
image2
The frame is the Background of the seekbar. If i change the size the frame size will be changed automatically. The thumb will not changed
Related
I am trying to create a custom seekbar. I have used vectors for progress drawable and thumb as:
android:thumb="#drawable/custom_seekbar_thumb"
android:progressDrawable="#drawable/custom_seekbar_progress"
android:splitTrack="false"
Right now my seekbar looks like this:
As you can see the pink vector image that I have used for progressDrawable doesn't occupy the entire width of seekbar - there is some gap between the drawable and seekbar in the right side.
How do I make my progress drawable occupy the entire width of the seekbar?
Fixed this issue simply by using android:paddingEnd="0dp" in Seekbar.
I want to have a custom Switch which I can define the Thumb and Track drawables.
Setting the thumb (no problem here):
android:thumb="#drawable/switch_button_selector"
Setting the track:
android:track="#drawable/switch_bg"
switch_bg is a drawable (image) on res/drawable folder and it is not a 9 patch image.
Happens that this drawable is being resized in height.
I want to keep its original size (width/height) without stretching the drawable.
Note: The thumb is bigger (in height) than the track.
You need to have the switch_bg image the exact same size as the thumb resource.
2 options for that:
1) Edit the image (png/etc) to have transparent spacing where it is needed to match the size of the thumb
2) Create a new drawable resource file of layer-list and add the switch_bg as a child. There you can set inner padding so that the overall resource will fit in size to the thumb
How can i increase seekbar thickness? I would like to have this horizontal line very thick plus have thumb with much bigger circle. (holo.light)
Do I really have to create my own drabawbles? I hoped that changing only some attributes would be enough....
I have a layout in Android which contains a SeekBar element. Both the height and width of the SeekBar are set as "fill_parent". The parent has a layout_weight, and changes size depending on the size of the screen on which it is displayed.
The problem I'm having is that I need to use a custom graphic as the thumb image on the SeekBar, but the image won't scale to match the SeekBar size. Sometimes it is too small, and other times too big. I tried adding android:scaleType="fitXY" to the SeekBar, but this didn't help. I also tried wrapping the thumb image in a ScaleDrawable, but this didn't work either.
Does anyone know how to accomplish this?
I'm having problems with a custom seekbar thumb (aka scrubber control). The thumb is clipping whenever I press on it, then goes away once I drag it. I've already added padding to the right and left of the seekbar to accommodate the thumb at the ends. This image shows what's happening at different stages of progress and while idle at either end:
I've also tried adding a thumb offset to the seekbar: android:thumbOffset="0dp". The result is no more clipping when pressed, but now the scrubber control does not move to the very end of the bar on either side. This image shows the seekbar with thumbOffset:
All of the scrubber control drawables are the same size, so the image size isn't changing size when the state becomes pressed. Is there some way to get no clipping while pressed and still have the scrubber control move to the very ends of the bar?
Use PaddingLeft and PaddingRight and thumbOffset attribute for your SeekBar.
Try setting your padding AND your thumbOffset to half the width of your thumb.
I.e. if the width of your thumb is 30, set padding="15dp" and thumbOffset="15dp"