我正在開發android中的動畫應用程序。 我在應用程序中有一個大的圖像。 圖像應該從屏幕中心開始。初始階段圖像尺寸會更大。在移動到屏幕左側時,其大小應該會減小(即縮放應該發生)。圖像不應該回到原來的位置。在動畫之後,它應該放置在屏幕的左側。如何使圖像小於原始大小?
任何人都可以請幫忙。 感謝你。
我正在開發android中的動畫應用程序。 我在應用程序中有一個大的圖像。 圖像應該從屏幕中心開始。初始階段圖像尺寸會更大。在移動到屏幕左側時,其大小應該會減小(即縮放應該發生)。圖像不應該回到原來的位置。在動畫之後,它應該放置在屏幕的左側。如何使圖像小於原始大小?
任何人都可以請幫忙。 感謝你。
如果我理解conrrectly要顯示的圖像,然後使其appers的大小來減少給人的影響是進入後臺製作動畫。
您需要使用ScaleAnimation http://developer.android.com/reference/android/view/animation/ScaleAnimation.html
關於機器人動畫很好的教程,可以發現:從中心 http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/#Scale_Animations
感謝Orlymee,它的工作原理。圖像在屏幕上縮放,但現在我想停止特定點的圖像縮放,我怎麼能做到這一點? – naleshmadur 2012-02-22 05:20:51
此功能調整位圖
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
matrix.postRotate(90);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height,
matrix, false);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
resizedBitmap.compress(Bitmap.CompressFormat.PNG, 70, bytes);
return resizedBitmap;
}
,你可以移動它的位置,通過翻譯圖像矩陣 – 2012-02-21 12:54:41
你的意思是要進行動畫處理,調整了嗎? – Shaheer 2012-02-21 12:37:51
http://stackoverflow.com/questions/2243335/how-to-display-animated-images-in-android – Triode 2012-02-21 12:44:23
我想使它更小,而不是它的原始大小,它應該向後移動,同時調整大小 – naleshmadur 2012-02-21 12:45:15