Ramotion / fluid-slider-android

:octocat:💧 A slider widget with a popup bubble displaying the precise value selected. Android library made by @Ramotion
https://www.ramotion.com/agency/app-development/
MIT License
1.42k stars 147 forks source link

direction rtl #31

Closed freehussain closed 5 years ago

freehussain commented 5 years ago

hello,

i want to use this for direction rtl, can you help me please?

kind regards

golovin47 commented 5 years ago

Hello, @freehussain. You can use it with rtl. Steps to apply:

  1. Use your startText as endText and your endText as startText in fluidSlider.
  2. Use inverted position in positionListener callback function.

Example:

val max = 45 val min = 10 val total = max - min

val slider = findViewById(R.id.fluidSlider) slider.positionListener = { pos -> val invertedPosition = 1f - pos; slider.bubbleText = "${min + (total * invertedPosition).toInt()}" } slider.position = 0.7f slider.startText ="$max" slider.endText = "$min"

This is the simplest way to use fluidSlider with rtl (invertion of values). Other way is changing the source code inside the library.