티스토리 뷰

728x90
반응형


Fragment setCustomAnimations()



R.animator.slide_up


1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:propertyName="translationY"
        android:valueType="floatType"
        android:valueFrom="1280"
        android:valueTo="0"
        android:duration="@android:integer/config_mediumAnimTime"/>
cs



R.animator.slide_up


1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:propertyName="translationY"
        android:valueType="floatType"
        android:valueFrom="0"
        android:valueTo="1280"
        android:duration="@android:integer/config_mediumAnimTime"/>
cs



애니메이션 적용


1
2
3
4
5
6
7
getFragmentManager().beginTransaction()
                .setCustomAnimations(R.animator.slide_up,
                        R.animator.slide_down,
                        R.animator.slide_up,
                        R.animator.slide_down)
                .add(R.id.list_fragment_container, Fragment)
                .addToBackStack(null).commit();
cs



메서드를 호출하는 순서가 중요하다고 한다


실제로 내 경우 setCustomanimations() 를 add 이후에 호출하였더니 적용되지 않았다


add 전에 호출해주는 것이 중요하다



References


http://trickyandroid.com/fragments-translate-animation/


https://stackoverflow.com/questions/6993863/fragmenttransation-setcustomanimations-not-working


반응형
공지사항
최근에 올라온 글