2

I am making a custom SeekBar as following image.

Custom SeekBar with separator

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"/>
Thiha Zaw
  • 806
  • 1
  • 9
  • 25

2 Answers2

7

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:

  1. Open your project build.gradle (root folder) and add:

    allprojects {
        repositories {
            maven { url "http://dl.bintray.com/arnoult-antoine/maven/" }
            ...
        }
    }
    
  2. In app main module (probably "app" directory) build.gradle file for compile library add:

    dependencies {
        ...
        compile 'com.aat:android-comboseekbar:1.0.2@aar'
    }
    
  3. 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" />
    
  4. 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);
    
  5. Enjoy your Combo Seekbar:

enter image description here

sswierczek
  • 810
  • 1
  • 12
  • 19
  • Thank you. But, it shows only normal SeekBar in sample project. Actually, I'm just new to android and please may I know how to use it. – Thiha Zaw Nov 21 '15 at 18:59
  • @ThihaZaw see my edit I added detailed example how to use it. – sswierczek Nov 22 '15 at 13:25
  • @SebastianŚwierczek Unrelated, but how did you find the project AAR? – Jason John Jan 21 '16 at 17:54
  • 1
    @jaytj95 it is used in sample https://github.com/karabaralex/android-comboseekbar/blob/master/sample/build.gradle and the maven url is in main build.gradle here https://github.com/karabaralex/android-comboseekbar/blob/master/build.gradle – sswierczek Jan 21 '16 at 20:15
  • I'm still a little confused. I forked this project and now I want to use my forked project via gradle. How do I go about doing this? https://github.com/jaytj95/android-comboseekbar/tree/patch-1 – Jason John Jan 22 '16 at 18:20
  • how to reduce size of deselected dot ? Please give some suggestion – Anand Savjani Aug 21 '16 at 12:23
  • 1
    @AnandSavjani it is not possible in this library but... I forked it as original repository was removed and added `dotRadius` and `thumRadius`. You have to download my new release [1.1.0](https://github.com/sswierczek/android-comboseekbar/releases) and use `cbs:dotRadius` and `cbs:thumbRadius` to change theirs size. Check out sample usage [here](https://github.com/sswierczek/android-comboseekbar/blob/master/sample/src/main/res/layout/activity_main.xml), and my changes to achieve this [here](https://github.com/sswierczek/android-comboseekbar/commit/895d2813fabccd327544b7b804b3996952e30589) – sswierczek Aug 21 '16 at 18:09
  • @sswierczek : how to set spacing between text and dot ? because its showing to much messy.please help for that – Anand Savjani Aug 26 '16 at 08:31
  • @AnandSavjani I added attribute `cbs:textBottomPadding` in version [1.2.0](https://github.com/sswierczek/android-comboseekbar/releases/tag/v1.2.0). Please also up vote my answer if you find it useful. – sswierczek Aug 27 '16 at 12:36
0

Whatever you are looking for is here

See here.

It can customize the separator and text, and there are listeners as well.

Rohit
  • 2,646
  • 6
  • 27
  • 52
hongbeomi
  • 1
  • 1