Search code examples
androidseekbar

Creating a SeekBar position popup in Android


I have a SeekBar in my application, and I want it to behave so that when the user is dragging the 'thumb', a Popup appears above the thumb (and follows it as the thumb is dragged), and the Popup displays the corresponding positon of the SeekBar (or any other text that position may represent).

Any suggestions?


Solution

  • The solution I found for this popup following the seek bar is to put the textview in a relative layout right above the seekbar. Then, in seekbar's onProgressChange, set the textView's left margin accordingly using

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(widht, height)
    params.setLeftMargin(margin)
    

    works great, with some tweaking!

    cheers