I\'m using a drawable for seekbar thumb with
android:thumb=\"@drawable/thumb\"
How can I set the size of this thumb in dip
I wanted to update @andrew 's answer with a more detailed answer since its been 7 years ..
Just as he said ;
You should create layered-drawable thumb_image.xml (Please keep it in the drawable folder) :
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<size
android:height="40dp"
android:width="40dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:drawable="@drawable/scrubber_control_normal_holo"/>
Then you should add this property line to your SeekBar in layout file :
android:thumb="@drawable/thumb_image"
When you do just this, Android Studio will tell you that it couldn't find "scrubber_control_normal_holo.xml" in your @drawable folder
So you should put it in there. You can find this type of android resources in your SDK folder. By default, the Android Studio IDE" will be installed in "C:\Program Files\Android\Android Studio", and the "Android SDK" in c:\Users\username\AppData\Local\Android\Sdk.
In your SDK folder you should follow this path platforms->android-xx->data->res->drawable
Then in this "drawable" folder you can find scrubber_control_selector_holo.xml , You should copy it to your Android project's drawable folder.
Now android studio will be able to find scrubber_control_selector_holo.xml , but its not working yet because in this .xml file ; there is 4 more files you need to copy in order to achive the supreme singularity of evolution. Or else Android studio will give you an error like this : " Resource linking failed because somethings are private blablabla "
scrubber_control_disabled_holo
scrubber_control_pressed_holo
scrubber_control_focused_holo
scrubber_control_normal_holo
I found these files in platforms->android-xx->data->res->drawable-mdpi (Different dpi options for different sizes, I used the ones in mdpi)
Copy these .png files into your @drawable folder too.
Then as a final step (I'm sorry for this answer being too long but I didn't want any confusions)
You should edit these lines of your scrubber_control_selector_holo.xml file :
android:drawable="@android:drawable/scrubber_control_disabled_holo" />
android:drawable="@android:drawable/scrubber_control_pressed_holo" />
android:drawable="@android:drawable/scrubber_control_focused_holo" />
android:drawable="@android:drawable/scrubber_control_normal_holo" />
You should replace this "@android:drawable" parts with "@drawable" to your your projects resources not the ones in android.
It should work fine now ☺
Another simple solution that worked for me was using scaleX
and scaleY
. The entire seekbar will be larger this way and not just the thumb.
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleX="2"
android:scaleY="2" />