Android Question Rotary knob post!

Beja

Expert
Licensed User
Longtime User
Hello all,
After searching for a post about a rotary knob that has steps (not continuous).. I finally gave up
the switch jumps from one value to another like that of the washing machine. any help appreciated.

knob-marks.png
 

derez

Expert
Licensed User
Longtime User
I use these two subs in a clock application to rotate the clock's hands, it is the same as what you want with the change of starting angle and angle difference for each step:
B4X:
Sub setRotation(v As View, Angle As Float)
    Dim jo = v As JavaObject
    jo.RunMethod("setRotation", Array As Object(Angle))
End Sub

Sub drawhand(lbl As Label, index As Double)
    Dim q As Double = 270 + 6 * index
    setRotation(lbl,q)
End Sub
Add a click event to make the knob rotate to the next step.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
I use these two subs in a clock application to rotate the clock's hands, it is the same as what you want with the change of starting angle and angle difference for each step:
B4X:
Sub setRotation(v As View, Angle As Float)
    Dim jo = v As JavaObject
    jo.RunMethod("setRotation", Array As Object(Angle))
End Sub

Sub drawhand(lbl As Label, index As Double)
    Dim q As Double = 270 + 6 * index
    setRotation(lbl,q)
End Sub
Add a click event to make the knob rotate to the next step.

Thanks derez
Some time ago I read a post with realistic graphical knob.. but now can't find it.. will try your solution.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You may have a look at this project, I made it as a XUI challenge.
It is a XUI B4X CustomView.
It needs some improvements.
At the moment it doesn't work yet with B4i, will be fixed.
You can turn the button, and it snaps onto the nearest value.
A click in the middle selects the next value, a LonkClick in the middle selects the prevous value.

upload_2018-8-1_16-54-45.png


EDIT: 2018.08.11
Removed the zip file.
A new version is HERE.
 
Last edited:
Upvote 0
Top