Programming/Non programming

Thursday, March 4, 2010

Android: Animation support on Android

Android:

Animation support on Android

I.
Core Animation: Animation can be applied to Views, Surfaces and other objects.
Animations are available for, Translation, Rotation, ScaleAnimation, Alpha Animation(Object level animation, fading etc) and AnimationSet(for combining several animations into one)

http://developer.android.com/intl/de/reference/android/view/animation/Animation.html
http://developer.android.com/intl/de/reference/android/view/animation/LayoutAnimationController.html

II.
Android supports tweened animation which includes rotations, fading, moving and stretching.

http://developer.android.com/intl/de/guide/topics/resources/available-resources.html

III.
Android supports 2D graphics library for drawing and animating shapes and images.

http://developer.android.com/intl/de/guide/topics/graphics/2d-graphics.html

IV)
Apart from the above, Android supports always Open GL ES 1.0 too for high end graphics.

Excellent tutorials available here:
http://developerlife.com/tutorials/?p=343

Some example sources are available in the below link:
http://www.deitel.com/ResourceCenters/Programming/Android/AndroidAnimation/tabid/3554/Default.aspx


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Android: How to zoom-in zoom-out images on Android

Android:

How to zoom-in zoom-out images on Android:

I.)
Sample code:

float scaleWidth, scaleHeight;
float zoom = 0.0f;

void ShowImage() {
Bitmap cur_bm = BitmapFactory.decodeFile(path);
float imageWidth = (float)cur_bm.getWidth();
float imageHeight = (float)cur_bm.getHeight();
float newHeight = imageHeight / (imageWidth / screenWidth);
float newWidth = screenWidth;
scaleWidth = screenWidth / imageWidth;
scaleHeight = newHeight / imageHeight;
image.setImageBitmap(cur_bm);
SetImageMatrix();

}

void SetImageMatrix() {
Matrix mtrx = new Matrix();
mtrx.postScale(scaleWidth, scaleHeight);
image.setImageMatrix(mtrx);
image.setScaleType(ScaleType.MATRIX);
image.invalidate();

}

void ZoomIn(float zoom) {
zoom += 0.01;
scaledWidth += zoom;
scaledHeight += zoom;
ShowImage();

}

void ZoomOut(float zoom) {
zoom -= 0.01;
scaledWidth -= zoom;
scaledHeight -= zoom;
}

II.) References:

http://groups.google.com/group/android-developers/browse_thread/thread/bdc4998a70f310c7

http://www.anddev.org/images_and_photos_zoom_in-out-t265.html


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..