I have created a bitmap image which is a circle and than as I wanted to animate it so i converted it into bitmapdrawable and than added it to animation drawable..But due to this the circle shaped has changed to oval shape...
So what should I do ?
Is there any other method to animate only the bitmap file. ?
Thanks in advance..
no, you can not animate the
bitmap
itself with theandroid animation framwork
. You can directly animateView
s orViewGroup
s and all the classes that derives fromView
andViewGroup
.Call
view
theImageView
that contains the bitmap.that should translate the
ImageView
by100px
from the current positionIf you're using Canvas, I'd suggest holding a pointer to the current Bitmap and loading all other Bitmaps into an array.
Say,
Select the currentFrame by pointing at the frame you're interested in.
So when you call drawBitmap(currentBitmap) it will only draw the frame you are interested in. You can change the bitmap every so many frames, by assigning an fps to the frame animation.
If you just want to scale or rotate the bitmap (rotating a circle?), the best way to resize a bitmap is using createScaledBitmap, and rotating using a matrix.
For Scaling, you load any bitmap into memory like this
If you would like the circle (or any bitmap) rescaled you would do something like this:
Where dstWidth and dstHeight are the target destination width and height, which you can previously calculate by scaling the original width and height.
And finally you would normally draw this Bitmap using a canvas like this
For rotating, create a Matrix
and finally
Keep in mind Canvases are slow for games or anything real-time!
Hope it helps.