fragmentTransaction.setCustomAnimations(
R.anim.enter,
R.anim.exit);
// 此处的自定义动画效果同Activity,此处不再过多描述
代码实战
第一步:activity_main.xml 的编写
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”
android:orientation=“vertical”>
<Button
android:onClick=“tiaozhuan”
android:id=“@+id/tv_hello_world”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“跳转Fragment”
android:layout_gravity=“center_horizontal”/>