rotate dial in limited degrees

…衆ロ難τιáo~ 提交于 2019-12-05 03:45:57

I do not understand your problem. The code below rotate the image 48 degrees.

ImageView dialer = (ImageView) findViewById(R.id.imageView_ring);

int degrees = 48;
Matrix matrix = new Matrix();
matrix.setRotate(degrees);
Bitmap bmpBowRotated = Bitmap.createBitmap(imageOrginal, 0, 0, imageOrginal.getWidth(),imageOrginal.getHeight(), matrix, false);

dialer.setImageBitmap(bmpBowRotated);

Hi Girish there is a class Named RotateAnimation by using this class u can easily do it

     look Example like

      RotateAnimation r = new RotateAnimation(0f, -90f,200,200); // HERE 
      r.setStartOffset(1000);
      r.setDuration(1000);
      r.setFillAfter(true); //HERE
      animationSet.addAnimation(r);

I would like to first know what will be there for deployment? Does it allow manipulation Evenets? if yes then you get handle ManipulationStatring and ManipulationDelta Event to rotate the element.
If the same is not the case where Manipulation is not available then you can try RenderTransformation property with RorateTransform of the element is you are working with WPf.

I was able to achieve this by doing few of the following tweaks on your code

  1. Making user click exactly on the arrow always to get the initial angle at which the arrow is placed, in your case 90 degree, else return false

  2. Also save the angle at which the user removed his finger and use that angle as the initial value for his next touch ,like if he placed arrow at 100 deg make that his initial touch position to activate rotation again

  3. Now for checking his answer take the angle at which your numbers 0 to 9 are placed ,im guessing your values take 120 deg from 0 to 9, divide that angle by 10, you can easily find out what angle represents what value and get your result

Also touching exactly at 90deg to begin rotation is very irritating, so always check for value which is bw 90+4 and 90-4 to begin, but always use the 90 as your start angle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!