旋转旋钮150度和210之间的移动旋钮

2023-09-06 07:31:45 作者:等待世末日

我按照 < STRONG>教程 并成功创建了一个旋光旋钮,但其旋转360度。不回采。我想如由进展到它从150到210度旋转。 ..

I have followed the tutorial and succesfully created a Rotatory knob but it rotate full 360 degree. without stoping . I want to rotate it from 150 to 210 degrees as shown by the progress. ..

怎么能修改它旋转150和210度之间。

How could i modify it to rotate between 150 and 210 degrees.

我的努力

我在OnDraw函数添加给检查

I have added given check in onDraw function

 protected void onDraw(Canvas c)
      {
          if(!(angle >150 && angle <210))
              c.rotate(angle,getWidth()/2,getHeight()/2); 

          super.onDraw(c);
      }

但它第一次停止它,并把它返回到180度,但正如我旋转两次或三次。角度可递增到430度以上,我的支票不工作。

But first time it stop it and take it back to 180 degree but as i rotate twice or thrice. The angle may be increment to 430 degree or above and my check don't work.

我只是想检查添加到给定code把它从150旋转到210,并希望将寻求改变监听器添加到它。

I simply want to add a check to the given code to rotate it from 150 to 210. and also want to add a seek change listener to it.

PocketMagic教程显示progresss正是我想要的,但它不是一个视图,我曾尝试创建这一点,但它扩展RelativeLayout的。

PocketMagic tutorial show progresss exactly what i want but it is not a view and i have tried creating this but it extends RelativeLayout.

和也看到了谷歌code资源这里,营造外部进度条

And also see a google Code resource here which create the outer Progress bar

推荐答案

您应该尽量限制角度哪里哪里它绘制它设置不是地方。这样,你仍然可以得到整个事情一致的状态。你的方式,角度将发生变化,但不会得到应用。

You should try limiting the angle at the place where it is set not where it is drawn. This way you still get consistent state of the whole thing. Your way, the angle will change but will not get applied.

我觉得你应该在年底公共布尔onTouch(视图V,MotionEvent事件)修改角度,使其留在边界。

I think you should modify the angle at the end of public boolean onTouch(View v, MotionEvent event) to make it stay in bounds.