2

I want to rotate a needle in an dealer, needle is image view and value comes from server. how to achieve this, i have also used rotation animation but no use. here is my sample code.

needle_img = (ImageView)findViewById(R.id.needleView2);
RotateAnimation rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,         Animation.RELATIVE_TO_SELF, 0.5f);
needle_img.setAnimation(rotate);

        rotate.start();

any help will be appreciable

Saad Bilal
  • 1,767
  • 1
  • 17
  • 31
  • possible duplicate of [Rotating Image on A canvas in android](http://stackoverflow.com/questions/8712652/rotating-image-on-a-canvas-in-android) – Aleks G Oct 21 '14 at 14:03
  • set scaleType = matrix and rotate the Matrix accordingly – pskink Oct 21 '14 at 14:07
  • what's the problem? what does this code actually do? what would you like it to do? – Gil Moshayof Oct 21 '14 at 14:23
  • This code does nothing for me, i have speedometer as an image and a needle also as image, i want to rotate needle on speedometer according to values, i get from server through API as decimal – Saad Bilal Oct 21 '14 at 14:27
  • Have a look at the linked (duplicate) question - there's code there for drawing an image at rotation. Get the bitmap of the needle from the resources, then use that code to draw it rotated onto the canvas of the speedometer's imageview. – Aleks G Oct 21 '14 at 14:32
  • its now moving, but i want needle pivot point remains same, but its not happening – Saad Bilal Oct 22 '14 at 08:01

0 Answers0