Closed chanben2005 closed 3 years ago
You can use this simple math to calculate the percent of end point for your section:
endSection = (speedValueAtEnd - minSpeed) / (maxSpeed - minSpeed)
For your values:
val endSection1 = (15 - 10) / (50 - 10)
// So this is your first section
val section1 = Section(0f, endSection1, Color.BLUE)
// For second section
val endSection2 = (30 - 10) / (50 - 10)
val section2 = Section(endSection1, endSection2, Color.GREEN)
val section3 = Section(endSection2, 1f, Color.RED)
speedometer.addSections(section1, section2, section3)
Then you need custom ticks, something like this:
speedometer.ticks = arrayListOf(0f, endSection1, endSection2, 1f)
For indicator you will need to build a custom indicator or use ImageIndicator.
I am follow to try, but tick can't fix the specified position.
The value 30 is the middle of your range (10 to 50) that's why it shows in middle. However, if you want to use different visual values I suggest you to do this:
Thank you for your guidance. I will try it.
As shown in illustration. I want the blue range is 10 to 15, green range is 15 to 30, red range is 30 to 50.
another, can set short or long of indicator? I just find the "app:sv_indicatorWidth".
Thank you!