Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 494
Andrew Avatar asked Nov 05 '22 19:11

Andrew


1 Answers

Check out this blog

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
   // TODO Auto-generated method stub
        RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT,
        RelativeLayout.LayoutParams.WRAP_CONTENT);
        p.addRule(RelativeLayout.ABOVE, seekBar.getId());
        Rect thumbRect = bar.getSeekBarThumb().getBounds();
        p.setMargins(
        thumbRect.centerX(),0, 0, 0);
        textView.setLayoutParams(p);
        textView.setText(String.valueOf(progress));
    }
  });
 }
}
like image 142
Leebeedev Avatar answered Nov 13 '22 15:11

Leebeedev