0

Is there a function (or an XML tag) which allows to change the width of thumb in the seekBar dynamically , when the maxValue is changed . For example if the maxValue == 2 the Thumb takes the half of the whole Seekbar , then if maxValue is 3 , it takes the 1/3-th of the width , and so on .

artless noise
  • 21,212
  • 6
  • 68
  • 105
user3199577
  • 249
  • 2
  • 5
  • 14

3 Answers3

0

The SeekBar thumb can only be set in XML, not dynamically. What you are looking for is akin to a scrollbar. Views which are scrollable, like ListView, have these built in, so you don't need to do anything.

katzoft
  • 858
  • 8
  • 10
  • Iam using SeekBar for scrolling the `HorizontalScrollView` . Is there a way to set the scrollbar separately from scrollView ? – user3199577 Jan 28 '14 at 10:53
  • As far as I know, the HorizontalScrollView has its own scrollbars. Why are you trying to duplicate this functionality by adding a SeekBar? – katzoft Jan 28 '14 at 11:46
  • is there a margin for scrollbar , I dont want it to take all the width of the scrollView ? or can I change the design of the scrollbar ? – user3199577 Jan 28 '14 at 14:21
  • You can influence the look and feel of the scrollbar using themes and styles. – katzoft Jan 28 '14 at 14:39
0

You need to programatically implement the logic..by using thumsize and progress values and implementing OnSeekBarChangeListener

You can ask if you have any further queries :)

Jigar Pandya
  • 2,129
  • 2
  • 17
  • 27
0

If you're targeting only android devices running v16+, you might be able to do this using getThumb().setBounds(), but doing so may have consequences if you do it whilst the user is touching the view.

You will also want to update the offset using setThumbOffset() passing in 1/2 the width of the new bounds.

You can also just replace the thumb with a new drawable, which will update the offset for you (if you have a symmetrical drawable), but adjust its bounds is probably going to be more efficient.

FunkTheMonk
  • 10,908
  • 1
  • 31
  • 37