I have a seekbar, while moving it I want to change values from 0 to 200. I have a TextView, where I display those values while moving the seekbar. But I don\'t want to have
You can also achieve this by defining custom SeekBar class as below
public class CustomSeekBar extends AppCompatSeekBar {
int SEEKBAR_MULTIPLIER = 1;
public CustomSeekBar(Context context) {
super(context);
}
public CustomSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setSeekBarConfig( int SEEKBAR_MULTIPLIER, int SEEKBAR_MAX){
setMax(SEEKBAR_MAX);
this.SEEKBAR_MULTIPLIER = SEEKBAR_MULTIPLIER;
}
@Override
public int getProgress() {
return super.getProgress() * SEEKBAR_MULTIPLIER;
}
}
And can use by following manner
CustomSeekBar mCustomSeekBar = (CustomSeekBar) findViewById(R.id.customSeekBar);
mSeekBar.setSeekBarConfig(10,20);
In xml you should add CustomSeekBar instead of SeekBar
<*.CustomSeekBar
com.quemb.qmbform.view:setSeekBarConfig="10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBar" />
So that you can reuse the custom seekBar in entire App with out repeating whole extra calculation.