Android SeekBar with separators

社会主义新天地 提交于 2019-12-06 08:12:24

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:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!