Search code examples
androidseekbar

SeekBar thumb at the middle of progress not at the starting point


How can I center the thumb of SeekBar so that If I scroll left it gives negative value and if I scroll right it gives me positive value??


Solution

  • Hope this would help.

    <SeekBar
            android:id="@+id/seekBar1"
            android:progressDrawable="@android:color/background_dark"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:progress="50"
            android:max="100" />
    

    And use int progress = mSeekBar1.getProgress()-50; to get the progress.