Android 프로젝트에서 간단한 애니메이션을 만들고 싶습니다.Android에서 애니메이션 순서를 회전하십시오.
<ImageView
android:id="@+id/pointer_png"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="@drawable/pointer_400" />
을 그리고 여기 활동 수업 시간에 내 온 클릭 방법이다 : 나는 나의 활동에 이미지를 가지고
public void onStartButtonClick(View view){
AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new LinearInterpolator());
animationSet.setFillAfter(true);
RotateAnimation anim = new RotateAnimation(0.0f, -45.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(4000);
animationSet.addAnimation(anim);
RotateAnimation anim2 = new RotateAnimation(0.0f, 90.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim2.setDuration(4000);
animationSet.addAnimation(anim2);
RotateAnimation anim3 = new RotateAnimation(0.0f, -135.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim3.setDuration(4000);
animationSet.addAnimation(anim3);
RotateAnimation anim4 = new RotateAnimation(0.0f, 180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim4.setDuration(4000);
animationSet.addAnimation(anim4);
final ImageView pointer = (ImageView) findViewById(R.id.pointer_png);
pointer.startAnimation(animationSet);
}
불행하게도, 그 효과는 예기치 않은가. 다음 순서로 이미지를 회전하고 싶습니다.
- 4 초 이내에 180도 회전합니다.
- 다음 4 초 이내에 -135도 회전.
- 다음 4 초 내에 90도 회전하십시오.
- 지난 4 초 이내에 -45도 회전.
그러나이 코드 애니메이션은 분명히 16 초보다 짧으며 한 부분 만 구성되어 있습니다 (0 점에서 90도까지 끝났습니다). 아마도 AnimationSet은 모든 애니메이션을 검사하고 시퀀스의 마지막 위치를 계산합니다. AnimationSet (false)을 설정하고 각 RotateAnimation에 별도의 LinearInterpolator를 추가하려고 시도했지만 작동하지 않습니다.
애니메이션을 길게 만들고 모든 회전을 분리하려면 어떻게해야합니까? (각 단계마다 4 단계, 4 초)?
'setStartOffset()'를 사용하여 다른 애니메이션에 시작 오프셋을 추가하십시오. – TR4Android
나는 0, 4000, 8000, 12000의 오프셋을 시도했지만, 최종 결과는 예상치 못했고 예상치 못한 결과였다. 각각의 애니메이션에 AnimationListener를 설정하고 onAnimationEnd 메소드를 오버라이드해야하고 다음 애니메이션을 시작할 필요가 있습니다. 이 시퀀스는 괜찮지 만 더 복잡한 애니메이션은 무엇입니까? – maniek099