2

So I have a SeekBar but the little circle thumb thing is kind of hard to grab. Is there a way to make the hitbox larger? I don't necessarily care if the graphic itself looks any different -- I just want it to be grabbable.

KaliMa
  • 1,970
  • 6
  • 26
  • 51

3 Answers3

2

You can customize the seekbar, Answered by Andrew, by changing the size of the Thumb. create layered-drawable with shape as placeholder thumb_image.xml

<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"/>
</layer-list>

The example shows the result below.

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumb="@drawable/thumb_image" />

Another good example here of Thumb customization.

Community
  • 1
  • 1
  • I had tried that solution but it couldn't find "scrubber_control_normal_holo" – KaliMa May 16 '17 at 13:48
  • You can download the necessary resources from here : http://android-holo-colors.com/ and then just add them to your Drawable folder. – Alex T May 16 '17 at 13:53
  • @KaliMa this is the scrubber_control_normal_holo.png image name, just use simple and smaller circle icon and name it scrubber_control_normal_holo and put it into the drawables, and use the above example as shown, You will get the answer. Try it, if it solves your problem, make it answered. – Muhammad Waseem May 16 '17 at 13:53
0

Check out this cool library for Seekbar DiscreteSeekBar

And can be added without much complexity by the following

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:dsb_min="2"
        app:dsb_max="15"
/>

Which has the following attributes as well.

dsb_progressColor: color/colorStateList for the progress bar and thumb drawable
dsb_trackColor: color/colorStateList for the track drawable
dsb_indicatorTextAppearance: TextAppearance for the bubble indicator
dsb_indicatorColor: color/colorStateList for the bubble shaped drawable
dsb_indicatorElevation: related to android:elevation. Will only be used on API level 21+
dsb_rippleColor: color/colorStateList for the ripple drawable seen when pressing the thumb. (Yes, it does a kind of "ripple" on API levels lower than 21 and a real RippleDrawable for 21+.
dsb_trackHeight: dimension for the height of the track drawable.
dsb_scrubberHeight: dimension for the height of the scrubber (selected area) drawable.
dsb_thumbSize: dimension for the size of the thumb drawable.
dsb_indicatorSeparation: dimension for the vertical distance from the thumb to the indicator.

Other SeekBar components in the library are these

Sreehari
  • 5,621
  • 2
  • 25
  • 59
0

You want an inset drawable resource. This answer to the question "Offset shape within a ShapeDrawable" https://stackoverflow.com/a/3674134/3175580 happens to be the same thing, you're asking. Like the other answer, you'll still need to copy the target drawable if it's private.

The advantage (or disadvantage) is that this shows you exactly how much you're increasing the size by, instead of the total size. Plus, I think it saves memory because using a Transparent shape will create a transparent bitmap of that size (?).

androidguy
  • 3,005
  • 2
  • 27
  • 38