I have a wheel, I want to rotate it on its position. my code is rotating this image but its going to change its position. i want to keep this image on fix place.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
dialImage = (ImageView) findViewById(R.id.inner_dial);
float rotation = (float) Math.toDegrees(90);
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
bMap = BitmapFactory.decodeResource(getResources(),
R.drawable.inner_temp);
dialImage.setBackgroundResource(0);
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(),
bMap.getHeight(), matrix, true);
dialImage.setImageBitmap(bMapRotate);
}
my xml file:
<?xml version="1.0" encoding="utf-8"?>
<ImageView android:background="@drawable/inner_temp"
android:layout_height="wrap_content" android:id="@+id/inner_dial"
android:layout_width="wrap_content" android:layout_alignParentLeft="true" />
Save this
rotate.xmlin theanimfolder inres.Start your animation:
EDIT:
To use rotate animation prgrammatically:
Follow this link for detailed description.