Skip to content Skip to sidebar Skip to footer

Stamina Mode Breaks Fragment Loading With Custom Animations

This code is working as expected on all devices except Sony devices with activated STAMINA mode: int backStackCount = getSupportFragmentManager().getBackStackEntryCount(); getF

Solution 1:

I used Roman Nurik's method for animating the Fragments. If the STAMINA mode is activated, the animations are disabled and the setXFraction method is called only once with the end value of the animation. The width of the View is 0 at this moment, so it's never going to be placed at the right position.

The solution is to delay the placement until the layout is finished:

publicvoidsetXFraction(float xFraction){
    this.xFraction = xFraction;
    post(() -> {
        finalint width = getWidth();
        setX((width > 0) ? (this.xFraction * width) : -9999);
    });
}

Post a Comment for "Stamina Mode Breaks Fragment Loading With Custom Animations"