我已经创建了动画箭头。当我按下按钮时,它会旋转 -45 度,然后返回箭头。我的问题是:我想将箭头停在 -45 度。当我再次单击该按钮时,它应该将箭头 -45 移动到 -90 等等。请帮我解决这个问题。谢谢
我在这里放置代码。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:fromDegrees="0"
android:toDegrees="-45"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="400"
/>
</set>
超空间跳跃.xml
package kh.qasim;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
public class CustomAnimationActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView image = (ImageView) findViewById(R.id.imageView1);
final Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
image.startAnimation(hyperspaceJump);
}
});
}
}
CustomAnimationActivity.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<ImageView android:id="@+id/imageView1" android:src="@drawable/up" android:layout_width="203dp" android:layout_height="148dp"></ImageView>
</LinearLayout>