Reputation: 2060
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.
Upvotes: 2
Views: 1495
Reputation: 3177
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 (?).
Upvotes: 0
Reputation: 121
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.
Upvotes: 2
Reputation: 5655
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
Upvotes: 0