Building Slider-Toggle

How would you go about building this for Android (both XML and Java-wise)? We need to know when the value changes to update the rest of the activity, and read the current value. I couldn't find any libraries to do this, do you know of any?

Slider Design GIF

1 answer

  • answered 2017-11-12 21:13 Anjal Saneen

    Take a look at this library here: Multi-State Toggle Button

    This is how it looks:

    enter image description here

    And it's quite easy to use it:

    <org.honorato.multistatetogglebutton.MultiStateToggleButton
        android:id="@+id/mstb_multi_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        mstb:values="@array/planets_array" />
    

    In your activity:

    MultiStateToggleButton button2 = (MultiStateToggleButton) this.findViewById(R.id.mstb_multi_id);
    button2.setOnValueChangedListener(new ToggleButton.OnValueChangedListener() {
        @Override
        public void onValueChanged(int value) {
            Log.d(TAG, "Value: " + value);
        }
    });