Reputation: 2092
Hy guys,
I've got a problem with an animation. I've got 2 fragments (A and B). A button in fragment A takes me to fragment B. I would like to get both fragments to animate up in the transition. The problem I've got, fragment B animates up covering fragment A, instead of both animating up. Here is my code:
slide in up animation
<translate
android:duration="500"
android:propertyName="y"
android:valueFrom="100%"
android:valueTo="0%"
android:valueType="floatType" />
slide out up
<translate
android:duration="500"
android:propertyName="y"
android:valueFrom="0%"
android:valueTo="-100%"
android:valueType="floatType" />
and the method in code:
public void showB() {
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(R.anim.slide_in_up, R.anim.slide_out_up)
.add(R.id.content, B.newInstanceAdd())
.commit();
}
Thank you in advance.
Upvotes: 1
Views: 884
Reputation: 4007
To replace the fragment use :
replace(R.id.content, B.newInstanceAdd())
instead of:
add(R.id.content, B.newInstanceAdd())
Otherwise it's up to you to hide/detach the previous fragment.
Upvotes: 2