我想要一個圖像旋轉無限期........這意味着我想循環它。這是我的嘗試,但不幸的是它不起作用。有什麼建議麼?Android Image旋轉
package com.android.test;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ImageView.ScaleType;
public class imagerotate extends Activity {
int x=1;
int y=3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout linearLayout = new LinearLayout(this);
while (y==3) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.postRotate(x);
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width,height, matrix, true);
BitmapDrawable bmd = new BitmapDrawable(rotatedBitmap);
ImageView imageView = new ImageView(this);
imageView.setImageDrawable(bmd);
imageView.setScaleType(ScaleType.CENTER);
linearLayout.addView(imageView, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView(linearLayout);
x+=1;
}
}
}
好................我不知道那是什麼意思.............但是可以請你直接給我一個教程或者什麼教導如何實現這一目標?或者你可以修復我的代碼並將其發佈到此處。這將有所幫助 – efa 2010-12-03 00:14:33