material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.34k stars 3.06k forks source link

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

Open ansman opened 4 years ago

ansman commented 4 years ago

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

hunterstich commented 4 years ago

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?

ansman commented 4 years ago

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

hunterstich commented 3 years ago

Hey @ansman,

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

ansman commented 3 years ago

@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.

hunterstich commented 3 years ago

Hmm, yea I can reproduce this as well.

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

kdrag0n commented 3 years ago

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

iRYO400 commented 3 years ago

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

pubiqq commented 2 years ago

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)