美文网首页
Fragment动画

Fragment动画

作者: lhl_012 | 来源:发表于2017-09-20 16:59 被阅读49次

fm_enter.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromXDelta="100%"
        android:toXDelta="0" />
</set>

fm_exit.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromXDelta="0"
        android:toXDelta="-100%" />
</set>

fm_pop_enter.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromXDelta="-100%"
        android:toXDelta="0" />
</set>

fm_pop_exit.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromXDelta="0"
        android:toXDelta="100%" />
</set>
val transaction = supportFragmentManager.beginTransaction()
        transaction.setCustomAnimations(R.anim.fm_enter, R.anim.fm_exit, R.anim.fm_pop_enter, R.anim.fm_pop_exit)
        transaction.replace(R.id.fragment, fragment)
        transaction.addToBackStack("")
        transaction.commit()

相关文章

网友评论

      本文标题:Fragment动画

      本文链接:https://www.haomeiwen.com/subject/bnmosxtx.html