I am trying to implement the Rotatory wheel in android, just like the image displayed below.I came across the tutorial from this link. But i want to implement just as shown in the below image.The wheel consists of individual images.Does anybody have any idea regarding this implementation?? Any help would be appreciated.
Thanks in advance.
Akash
To do this from scratch, you would need a way to transform your touch coordinates, into polar coordinates (to have the rotation angle). This can be done easily like this:
To rotate the imageview, or the element you are using to display your knob, you can use a matrix like this:
Where deg is the angle and ivRobor is the knob imageview.
A complete working sample for Android, is available on Google code at: https://code.google.com/p/android-rotaryknob-view/
Applied on OnTouchListener on the imageView through which i got three events namely:
On MotionEvent.ACTION_DOWN got the angle where the users touches and on MotionEvent.ACTION_UP got the angle where user releases.
After getting difference of the two angles,rotated the image of that angle.
After rotating the image checked the quadrant through angle and maintained int variable which incremented according to the quadrant and by fulfilling the condition set the new image(the desired one).
Maintained the click event according to the value of the int variable.
Check this out. Its simple and basic wheel implementation on android. but you can develop on top of that.
https://github.com/lib4/RotateWheelAndroid_lib4
Here is the complete code for this:
Here is the XML: