I'm creating a custom seek-bar with 2 thumbs, and seek-bar range is 0-10000000, My question is that I want to divide that seek-bar into 2 equal parts and first part range is 0-1000000 with default steps 10000 and second part range is 1000001-10000000 with default steps 100000.
There is a library over the GitHub using which you can solve your problem.Here is the link to library here
Add a dependency to your build.gradle:
dependencies {
compile 'com.crystal:crystalrangeseekbar:1.1.3'
}
Answering your questions:-
It is a double thumb range seek bar.
You can set minimum and maximum range of the seek bar using attributes
app:min_value="0" //minimum value
app:max_value="150" // maximum value
You can set step size using following attribute
app:steps="5"// add required step size here
Your XML code for seek bar will look like this:-
<com.crystal.crystalrangeseekbar.widgets.BubbleThumbSeekbar
android:id="@+id/rangeSeekbar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:corner_radius="10"
app:min_value="0"
app:max_value="100"
app:steps="5"
app:bar_color="#F7BB88"
app:bar_highlight_color="#E07416"
app:left_thumb_image="@drawable/thumb"
app:left_thumb_image_pressed="@drawable/thumb_pressed"
app:data_type="_integer"/>
In java class you can impement setOnSeekbarChangeListener()
like this:-
final CrystalSeekbar seekbar = new CrystalSeekbar(getActivity());
// get min and max text view
final TextView tvMin = (TextView) rootView.findViewById(R.id.textMin5);
final TextView tvMax = (TextView) rootView.findViewById(R.id.textMax5);
// set listener
seekbar.setOnSeekbarChangeListener(new OnSeekbarChangeListener() {
@Override
public void valueChanged(Number minValue) {
tvMin.setText(String.valueOf(minValue));
}
});
Hope this might help!! Thanks.