【发布时间】:2018-09-29 21:01:30
【问题描述】:
我在我的应用程序中使用 v4 支持片段。我有一个活动,用户可以通过单击按钮查看更多信息。信息屏幕应该从底部向上滑动,覆盖活动,当按下背部时,向下滑动。这是我目前正在使用的代码
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(
R.anim.fragment_bottom_enter,
R.anim.fragment_bottom_exit,
R.anim.fragment_bottom_exit,
R.anim.fragment_bottom_exit
);
ft.replace(R.id.fragmentContainer, fragment, TAG);
ft.addToBackStack(null);
ft.commit();
fragment_bottom_enter.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="100%p"
android:toYDelta="0%p" />
</set>
fragment_bottom_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fillAfter="true"
android:fromYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p" />
</set>
以上内容适用于进入动画(片段按预期从底部滑动)。但是从不播放流行动画。我什至尝试使用android内置的淡入淡出动画无济于事。任何有关解决此问题的帮助将不胜感激。
【问题讨论】:
-
放更多关于pop的细节。你怎么叫pop?
-
我没有从代码中调用 pop。我将片段添加到后台堆栈,当按下后退按钮时它会弹出
标签: android android-fragments android-animation