material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Motion] Shared Axis transitions are broken with Fragment 1.3.0-beta01

Open ansman opened this issue 4 years ago • 8 comments

Description: There are visual issues with the shared axis transitions when using Fragment 1.3.0-beta01 device-2020-10-02-174713.mp4.zip

The new fragment appears without animation.

Source code: I used the catalog app with the fragment version set to 1.3.0-beta01

Android API version: 30

Material Library version: Latest master (d88ff770be2fd0041a82ca4ae2d6000136e0eada)

Device: Google Pixel 4XL

ansman avatar Oct 02 '20 21:10 ansman

Hey Nicklas,

It looks like this is a known issue with Fragment 1.3.0* - https://issuetracker.google.com/issues/169874632 - likely caused by something related to https://android.googlesource.com/platform/frameworks/support/+/47c5e9d30d0304a7d1ac6a522c01a055b858ff28%5E%21/#F4.

I spoke with the AndroidX team and they said this should be solved once the above bug is fixed.

In the meantime, are you able to use Fragment 1.2.x?

hunterstich avatar Oct 12 '20 22:10 hunterstich

Unfortunately we've already migrated to the new fragment result listeners so down grading isn't an option at this point.

ansman avatar Oct 13 '20 16:10 ansman

Hey @ansman,

Any chance you're able to verify this is fixed with Fragment 1.3.0-beta02?

hunterstich avatar Nov 19 '20 14:11 hunterstich

@hunterstich Sorry for the long response time but I just got a chance to try this. The issue still persists with 1.3.0-rc01. The outgoing fragment animates just fine but the incoming fragment doesn't animate at all.

ansman avatar Jan 07 '21 16:01 ansman

Hmm, yea I can reproduce this as well.

I'll try to figure out what's going on.

hunterstich avatar Jan 08 '21 16:01 hunterstich

I think this is the same underlying bug as #1984, but the visual effects are different depending on the views used in the incoming fragment.

Examples of behavior with other views: RecyclerView and ScrollView

RecyclerView animates incorrectly and looks like it's strecthed. ScrollView has an exaggerated content animation and the scrollbar appears immediately without an animation, similar to the demo posted above.

A workaround is to set a solid background for the fragment:

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        // Workaround for AndroidX bug: https://github.com/material-components/material-components-android/issues/1984
        view.setBackgroundResource(R.drawable.solid_background)
    }

res/drawable/solid_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<color xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:attr/colorBackground" />

I'm not sure why this helps, but it gets the job done. Perhaps the animation scales are being calculated before the inner views are fully initialized, and the workaround fixes it by forcing the fragment's view to occupy all the space in the container immediately?

Correct behavior with the workaround: RecyclerView and ScrollView

kdrag0n avatar Mar 08 '21 02:03 kdrag0n

How is it going? Still exists in 1.3.2 Tested on Huawei P20 Lite

iRYO400 avatar Apr 13 '21 07:04 iRYO400

The future has come, and after 4d4f3cc the issue turned into a full-fledged regression:

Appcompat 1.1.0
(before 4d4f3cc)
Appcompat 1.4.0
(after 4d4f3cc)

pubiqq avatar Sep 19 '22 18:09 pubiqq