Vod*_*det 6 android android-fragments android-elevation
我在片段之间使用动画:
从左侧滑入:
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="2000"
android:valueTo="0"
android:valueType="floatType"
android:fillAfter="true"/>
</set>
Run Code Online (Sandbox Code Playgroud)
从右侧滑入:
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-400"
android:valueType="floatType"/>
</set>
Run Code Online (Sandbox Code Playgroud)
该动画将前一个片段向左移动,而新片段从右移。我将其与片段事务一起使用。
transaction.setCustomAnimations(R.animator.slide_in_from_left,R.animator.slide_in_from_right);
Run Code Online (Sandbox Code Playgroud)
当新片段出现时,我遇到了麻烦,他将其滑到旧片段的下面,为解决此问题,我在新片段上加了一个标高,但我想在21以下使用API解决方案。是否有可能将新片段强制在较旧的片段
Vod*_*det -2
如果fragment出现在另一个fragment下面是因为fragment容器不是好的容器类型
您需要将fragment放入FrameLayout或RelativeLayout中,如果您想测试,可以将fragment布局代码粘贴到fragment容器的底部进行预览