milosmns / circular-slider-android

Circular Slider UI Control for Android
GNU General Public License v3.0
307 stars 51 forks source link

SetAngle value and onSliderMoved Position values are different for same position.. #8

Closed gowrav closed 7 years ago

gowrav commented 8 years ago

I am trying to use it as a control for volume, but the values are not continuous they vary widely from 0.25 to -0.75..

I also need to limit the slider progress to a specific arc and not allow it to complete the whole circle..

milosmns commented 8 years ago

Limiting is not supported at the moment. I will mark this as "Help Wanted" so that other people can vote and/or apply the patches. Otherwise, you can fork the repository and try to manually add the functionality.

mikronesia commented 8 years ago

Hi @gowrav I noticed the same thing. I'm using mine for a moveable clock face from 0-12 hours. I wrote this function which converts the position (not sure if they're radians) (from 0-9:00 or 0 to -0.75) and then handles when things go off from 9:00-12:00 (or 0.25 back down to 0)

public static String convertAngleToTimeString(double angle) {
        double result;
        result = angle * -12;
        if (result < 0) {
            //Handles 9:00-12:00 where values go negative
            result = result + 12;
        }
        return String.format("%.2f", result);
}
milosmns commented 7 years ago

Okay so I've answered to #9 with a solution to a similar problem. Closing this as it is answered there.