我已經寫了下面的代碼來讓我的圖標旋轉到屏幕的中心,而是圍繞左上角(即ImageView的原點x = 0,y = 0)旋轉。設置ImageView或RotateAnimation的某些屬性應該很簡單,但我無法弄清楚。如何在中心點上旋轉一個android圖標?
public class IconPromoActivity extends Activity {
private static final float ROTATE_FROM = 0.0f;
private static final float ROTATE_TO = -10.0f * 360.0f;// 3.141592654f * 32.0f;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView favicon = (ImageView) findViewById(R.id.favicon);
RotateAnimation r; // = new RotateAnimation(ROTATE_FROM, ROTATE_TO);
r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, 0, 0, 40, 0);
r.setDuration((long) 2*1500);
r.setRepeatCount(0);
favicon.startAnimation(r);
}
}
你能解釋這一點。這樣我們可以根據我們的需要輕鬆修改。 – Nepster 2015-05-05 07:52:33
這就是我要找的。 – tounaobun 2015-06-04 09:39:33