Please help to define own XML drawable for SeekBar Thumb.
In this XML drawable I would like to define custom shapes for state_selected
and state_pressed
.
As I understand, in the SeekBar definition in XML we have to put android:thumb="@drawable/listview_bg_selector"
where listview_bg_selector
looks like:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/seekbar_thumb_default" />
<item android:state_pressed="true"
android:drawable="@drawable/seekbar_thumb_clicked"
/>
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/seekbar_thumb_selected"
/>
</selector>
But what to do next, I've tried here code from drawables with shapes, but nothing worked properly, I just saw default SeekBar. Are there any examples for this issue?
xml create a layout and inside the layout add a SeekBar. Specify the height width of SeekBar and the max progress that you want to use set progress to 0. This will create a customized Seekbar inside activity_main.
xml file, which has attrs android:width="28dp" and android:height="28dp" in the vector tag. Here we can change the size of the thumb. Save this answer.
android.widget.SeekBar. A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.
For future answer-seekers, I used holo-colors.com to create my own custom SeekBar
, which I am perfectly satisfied with.
They also provide functions to create other android elements such as Spinner
, Switch
, etc.
something like this solved the problem for me.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/seek_thumb_pic">
<shape android:shape="rectangle" />
</item>
</selector>
another way might be setting bounds in code but I`m not sure about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With