Android SeekBar with separators

匿名 (未验证) 提交于 2019-12-03 01:34:02

问题:

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"/> 

回答1:

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:



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