我有一個ImageView圖像。我需要旋轉這個圖像90去油脂,然後從左到右移動這個圖像。我管理如何做到這一點。我用AnnimationListener和旋轉完成後我開始moveAnimation()。但在運動圖像返回到原始外觀之前(旋轉之前)。旋轉Android:旋轉動畫和移動動畫組合
XML代碼rotation.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:toDegrees="90"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:startOffset="0"
/>
rotateAnimation()
private void rotateAnimation(){
Animation rotation = AnimationUtils.loadAnimation(getContext(), R.anim.rotate);
rotation.setRepeatCount(0);
rotation.setFillAfter(true);
rotation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
moveAnnimation();
}
});
moveAnnimation()
private void moveAnnimation(){
TranslateAnimation moveLefttoRight = new TranslateAnimation(0, 2000, 0, 0);
moveLefttoRight.setDuration(1000);
moveLefttoRight.setFillAfter(true);
moveLefttoRight.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
});
image.startAnimation(moveLefttoRight);
}
你能舉出你用來旋轉和移動圖像的示例代碼。 – Shachillies 2012-08-10 09:45:47
好的,但我給你我的意見..嘗試使用矩陣旋轉和類似的矩陣翻譯,這樣你的矩陣將集中和圖像視圖將不會重置。不要忘記在執行任何矩陣操作之前將imageview的屬性scaletype設置爲矩陣。 – Shachillies 2012-08-10 09:46:22
添加代碼看看吧plz – haawa 2012-08-10 16:55:00