问题
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.
..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
回答1:
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.
来源:https://stackoverflow.com/questions/27717535/rotatory-knob-moving-between-150-and-210-degree