Overview

HorizontalWheelView

Custom view for user input that models horizontal wheel controller. preview

demo gif

Installation

Add jitpack.io repository to your root build.gradle:

allprojects {
 repositories {
    jcenter()
    maven { url "https://jitpack.io" }
 }
}

Add the dependency to your module build.gradle:

compile 'com.github.shchurov:horizontalwheelview:0.9.5'

API

Method Description
void setListener(Listener listener) Add a listener that will be invoked when the user interacts with the view
void setRadiansAngle(double radians) Set the rotation angle in radians
void setDegreesAngle(double degrees) Set the rotation angle in degrees
void setCompleteTurnFraction(double fraction) Set the rotation angle in fraction, where 0f = 0°, 1.0f = 360°
double getRadiansAngle() Get the rotation angle in radians (-2π, 2π)
double getDegreesAngle() Get the rotation angle in degrees (-360°, 360°)
double getCompleteTurnFraction() Get the roatation angle in fraction (0f, 1.0f), where 0f = 0°, 1.0f = 360°
void setOnlyPositiveValues(boolean onlyPositiveValues) When true, all rotation getters return only positive values, in xml: app:onlyPositiveValues, default: false
void setMarksCount(int marksCount) Set the total number of marks on the wheel, in xml: app:marksCount
void setNormalColor(int color) Set the color of non-active marks, in xml: app:normalColor, default: ffffff
void setActiveColor(int color) Set the color of active marks, in xml: app:activeColor, default: 54acf0
void setShowActiveRange(boolean show) When true, all marks that satisfy the condition |markAngle| <= |rotationAngle| will be highlighted with the active color, in xml: app:showActiveRange, default: true
void setEndLock(boolean lock) When true, it's not allowed to rotate the wheel past the edge values, default: false
void setSnapToMarks(boolean snapToMarks) When true, user's rotations will snap to the marks, in xml: app:snapToMarks, default: false

License

Copyright 2016 Mykhailo Shchurov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Make scrolling finite

    Make scrolling finite

    In the current version you can turn the wheel to left or to the right infinite times. I would like the option to have it finite and stop the scrolling at the max or min values, something like a volume control. Then the library could be used as an alternative to a seek bar.

    opened by ZiroDiv 7
  • Added vertical functionality and relevant sample.

    Added vertical functionality and relevant sample.

    TODO: Rename some variables. Also maybe merge vertical and horizontal views to a single widget

    I have seen that there is a vertical branch already but I am not sure about it's progress

    opened by ZiroDiv 7
  • Allow deterministic values

    Allow deterministic values

    At the moment all methods return float values.

    I want to have only a couple values (5) in the wheel. To do that two additional methods (beside setMin/setMax) should be added.

    Add a method setIntegerValues(boolean) which will force view to return only int values. Add a method setMarkInterval(int) to say when exactly marks should be drawn.

    Then I can say in the code: view.setMin(0); view.setMax(4); view.setIntegerValues(true); view.setMarkInterval(1);

    opened by alexeyvasilyev 5
  • How can I stop the touch?

    How can I stop the touch?

    Hello, I use the Android studio, I added compile compile 'com.github.shchurov:horizontalwheelview:0.9.5' to the build.gradle file.

    How can I stop the touch?

    opened by JungYongWook 3
  • More customization

    More customization

    Great library!

    In the next update I would like to be supported, for all values (int, floats, time, date etc..)

    • Set min value
    • Set max value
    • Set start value
    opened by webserveis 3
  • Mark gap space between marks

    Mark gap space between marks

    Is there any solution to find space between visible marks.

    when number of marks count is less than 40 ,the space between mark automatically increase.

    can you please update regarding space between marks.

    private void setupGaps(double step, double offset) { gaps[0] = (float) Math.sin(offset / 2); float sum = gaps[0]; double angle = offset; int n = 1; while (angle + step <= Math.PI) { gaps[n] = (float) Math.sin(angle + step / 2); sum += gaps[n]; angle += step; n++; } float lastGap = (float) Math.sin((Math.PI + angle) / 2); sum += lastGap; if (n != gaps.length) { gaps[gaps.length - 1] = -1; } float k = view.getWidth() / sum; for (int i = 0; i < gaps.length; i++) { if (gaps[i] != -1) { gaps[i] *= k; } } }

    opened by bhavinsetubridge 1
  • How to use this?

    How to use this?

    I'd like to use it in the ongoing project. But I don't know how to use it. Can you explain it?

    Build gradle file is created. I just want the wheel part.All the images of the rocket have been removed.

    Touch also disabled. But I don't know how to put it on my project.

    opened by JungYongWook 1
  • How to set Wheel color

    How to set Wheel color

    Hello, I use the Android studio, I added compile compile 'com.github.shchurov:horizontalwheelview:0.9.5' to the build.gradle file.

    But because of the applied background color The color of the wheel is blue, not similar to orange. void setActiveColor(int color) I think I need to use this code, but I need help with what to do.

    opened by JungYongWook 0
Owner
Mike Shchurov
Mike Shchurov