Rotatory knob moving between 150 and 210 degree
Asked Answered
C

1

1

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. enter image description here ..

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

My effort

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);
      }

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.

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 tutorial show progresss exactly what i want but it is not a view and i have tried creating this but it extends RelativeLayout.

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

Costar answered 31/12, 2014 at 7:7 Comment(0)
M
0

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.

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

Moidore answered 31/12, 2014 at 10:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.