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()
网友评论