I am making a custom SeekBar as following image.
after searching through internet, I couldn't find the best solution to meet for this issue. The following code is normal SeekBar control and please help me to change like above image.
<SeekBar
android:id="@+id/seekBar"
android:layout_width="fill_parent"
android:layout_height="@dimen/sbumit_form_field_height"
android:layout_marginTop="@dimen/sbumit_form_field_top_mergin"
android:layout_marginLeft="@dimen/sbumit_form_field_side_mergin"
android:layout_marginRight="@dimen/sbumit_form_field_side_mergin"
android:max="6"/>
Your image shows exactly this library (my fork). If You are not allowed to use it You can at least check solution and write Your own code.
Check ComboSeekbar onDraw method.
Check forked ComboSeekbar onDraw method.
Usage example:
Open your project build.gradle (root folder) and add:
allprojects { repositories { maven { url "http://dl.bintray.com/arnoult-antoine/maven/" } ... } }
In app main module (probably "app" directory) build.gradle file for compile library add:
dependencies { ... compile 'com.aat:android-comboseekbar:1.0.2@aar' }
Go to your XML layout file and put:
<com.infteh.comboseekbar.ComboSeekBar xmlns:cbs="http://schemas.android.com/apk/res-auto" android:id="@+id/comboseekbar" android:layout_width="match_parent" android:layout_height="wrap_content" cbs:myColor="@android:color/black" cbs:textSize="16sp" />
In Activity onCreate init it with for example this code:
ComboSeekBar comboSeekBar = (ComboSeekBar) findViewById(R.id.comboseekbar); List<String> points = new ArrayList<>(); points.add("Point 1"); points.add("Point 2"); points.add("Point 3"); points.add("Point 4"); comboSeekBar.setAdapter(points);
Enjoy your Combo Seekbar:
来源:https://stackoverflow.com/questions/33846767/android-seekbar-with-separators