ViewSwitcher 프로그래밍 방식으로 애니메이션을 설정하십시오
-
11-12-2019 - |
문제
i 이런 레이아웃에서 애니메이션을 설정합니다.
<ViewSwitcher
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inAnimation="@android:anim/slide_in_left"
android:outAnimation="@android:anim/slide_out_right" >
.
어떻게 프로그래밍 방식으로 동일하게 할 수 있습니까?
해결책
ViewSwitcher
클래스의 설명서를 읽으십시오. IN / OUT 애니메이션을 설정하는 두 가지 방법이 있습니다.
// load the two animations
Animation animIn = AnimationUtils.loadAnimation(context, android.R.anim.slide_in_left);
Animation animOut = AnimationUtils.loadAnimation(context, android.R.anim.slide_out_right);
// set them on the ViewSwitcher
vs.setInAnimation(animIn);
vs.setOutAnimation(animOut);
. 다른 팁
viewswitcher.setInAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
viewswitcher.setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_out));
. AnimationUtils
로 애니메이션을로드하는 단계를 건너 뛰고 Anim 리소스를 직접 전달할 수 있습니다.
switcher.setInAnimation(this, android.R.anim.slide_in_left);
switcher.setOutAnimation(this, android.R.anim.slide_out_right);
. 제휴하지 않습니다 StackOverflow