我已为Fragment
转换添加了动画,但说Fragment
有2个ImageViews
并附加了2个侦听器,因此第一次加载Fragment
隐藏动画,但下一个动作正常。
以下是我制作动画的方法:
public void replaceFragment(final Fragment fragment) {
FragmentManager fragmentManager = TrakrActivity.this.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction().addToBackStack("AboutFragment");
fragmentTransaction.setCustomAnimations(R.anim.enter_animation,
R.anim.stay, R.anim.stay, R.anim.exit_animation).replace(R.id.content_frame,
fragment, "KEY").commit();
}
如果我的ImageViews
被加载后才能开始这个动画才能拥有顺畅的用户体验?
编辑:
我的图片会手动添加到我的.xml
:
<LinearLayout
android:id="@+id/picture_layout"
android:layout_below="@id/email_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/picture_layout_height"
android:layout_alignStart="@id/email_layout"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_alignLeft="@id/dev_buy_layout"
android:layout_marginTop="@dimen/picture_layout_height">
<ImageView
android:id="@+id/github_image"
android:layout_width="@dimen/pictures_width"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/github_logo"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin" />
<ImageView
android:id="@+id/linkdin_image"
android:layout_width="@dimen/pictures_width"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/linkedin_logo" />
</LinearLayout>