Android 애니메이션(조합)
3038 단어 Android
애니메이션 초기화
1、
//移動アニメーション初期化
private TranslateAnimation translateAnimation;
{
//Animation.RELATIVE_TO_PARENT 親のViewに対して
//Animation.RELATIVE_TO_SELF 自分のViewに対して
translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT,0, //"X"開始位置のタイプとValue
Animation.RELATIVE_TO_PARENT,0.3f, //"X"終了位置のタイプとValue
Animation.RELATIVE_TO_PARENT,0, // "Y"開始位置のタイプとValue
Animation.RELATIVE_TO_PARENT,0.3f // "Y"終了位置のタイプとValue
);
//アニメーションの時間
translateAnimation.setDuration(500);
//アニメーションの回数数字または Animation.INFINITE(無限回)
//translateAnimation.setRepeatCount(Animation.INFINITE);
translateAnimation.setRepeatCount(3);
//アニメーション停止したら最後の位置に停止する
translateAnimation.setFillAfter(true);
//アニメーションのMode
translateAnimation.setRepeatMode(Animation.REVERSE);
}
private RotateAnimation rotateAnimation;
{
rotateAnimation = new RotateAnimation(
0,360, //開始と終了度数
Animation.RELATIVE_TO_SELF,0.5f, //回転の中心作業X
Animation.RELATIVE_TO_SELF ,0.5f //回転の中心作業Y
);
//回転回数
rotateAnimation.setRepeatCount(3);
//回転時間
rotateAnimation.setDuration(500);
}
//消えるアニメーション初期化
private AlphaAnimation alphaAnimation;
{
alphaAnimation = new AlphaAnimation(
1,
0
);
alphaAnimation.setDuration(500);
//消えた後表示しない
//alphaAnimation.setFillAfter(true);
//消えた後再表示
//alphaAnimation.setFillAfter(false);
alphaAnimation.setRepeatMode(Animation.REVERSE);
alphaAnimation.setRepeatCount(3);
}
//大きさアニメーション
private ScaleAnimation scaleAnimation;
{
scaleAnimation = new ScaleAnimation(
1f,3.0f, //Xの開始大きさ
1f,3.0f, //Yの開始大きさ
Animation.RELATIVE_TO_SELF,0.5f, //開始位置の位置X
Animation.RELATIVE_TO_SELF,0.5f //開始位置の位置Y
);
scaleAnimation.setDuration(500);
scaleAnimation.setRepeatCount(3);
scaleAnimation.setRepeatMode(Animation.REVERSE);
}
2. 애니메이션 nset의 초기화, 애니메이션 nset에 애니메이션을 추가해도 OK animationSet2 = new AnimationSet(false);
animationSet2.addAnimation(rotateAnimation);
animationSet2.addAnimation(translateAnimation);
3. animationsize가 청중의 추가 완성을 완성한 후에 다음 애니메이션을 시작합니다. animationSet2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
L.d("animationSet2 完了");
imageView3.startAnimation(animationSet3);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
소스 코드
Reference
이 문제에 관하여(Android 애니메이션(조합)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/YanHengGo/items/dadd25f4bde1f40ddb06텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)