왼쪽에서 슬라이드 In 한뒤에 다시 오른쪽으로 슬라이드 Out 하는 예제

final View panel = view.findViewById(R.id.overlay_chat_join); final Animation slideLeft = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_left); panel.startAnimation(slideLeft); Handler h = new Handler(); h.postDelayed(new Runnable() { @Override public void run() { Animation slideRight = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_right); panel.startAnimation(slideRight); slideRight.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { wm.removeView(view); } }); } }, 2000); slide_left.xml 는 아래와 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromXDelta="100%"
    android:toXDelta="0%" />
slide_right.xml 는 아래와 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromXDelta="0%"
    android:toXDelta="100%" />
]]>

Related Posts