Search code examples
androidseekbar

Android Seekbar with markers


I need a seekbar with markers like:

seekbar with red markers

I only need a background representing the red markers but the position of those markers need to be changed programmatically.

Any hints?

Thanks!


Solution

  • <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="40dp" >
    
            <View
                android:id="@+id/seek_divider_1"
                android:layout_width="3dp"
                android:layout_height="fill_parent"
                android:layout_marginLeft="50dp"
                android:background="#FF0000" />
    
            <View
                android:id="@+id/seek_divider_2"
                android:layout_width="3dp"
                android:layout_height="fill_parent"
                android:layout_alignParentRight="true"
                android:layout_marginRight="30dp"
                android:background="#FF0000" />
    
            <SeekBar
                android:id="@+id/seekBar1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="false"
                android:layout_alignParentLeft="false"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:background="@null" />
    
        </RelativeLayout>
    

    makes:

    result

    To change their position simply set their margin/-left or margin-right accordingly.

    It's a 'hack' over anything else. but it should work?