如何创建转轮控件? [英] How To Create a Rotating Wheel Control?

查看:23
本文介绍了如何创建转轮控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在android中实现转轮,就像下面显示的图像.我从这个链接.但我想实现如下图所示.轮子由单独的图像组成.有人对这个实现有任何想法吗?任何帮助将不胜感激.

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.

提前致谢.

阿卡什

推荐答案

应用在imageView上的OnTouchListener上,通过它我得到了三个事件:

Applied on OnTouchListener on the imageView through which i got three events namely:

  1. MotionEvent.ACTION_DOWN
  2. MotionEvent.ACTION_MOVE &
  3. MotionEvent.ACTION_UP.
  1. MotionEvent.ACTION_DOWN,
  2. MotionEvent.ACTION_MOVE &
  3. MotionEvent.ACTION_UP.

在 MotionEvent.ACTION_DOWN 上获得用户触摸的角度,在 MotionEvent.ACTION_UP 上获得用户释放的角度.

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.

旋转图像后,通过角度检查象限并保持 int 变量,该变量根据象限递增,并通过满足条件设置新图像(所需的图像).

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).

根据int变量的值维护点击事件.

Maintained the click event according to the value of the int variable.

这篇关于如何创建转轮控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆