material-components / material-components-android

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

LinearProgressIndicator showAnimationBehavior/hideAnimationBehavior issue #1972

Open alessandroToninelli opened 3 years ago

alessandroToninelli commented 3 years ago

using these 2 property and the Navigation components library, the LinearProgressIndicator not showed in fragments that aren't set as "start fragment" in navigation_graph

alessandroToninelli commented 3 years ago

https://developer.android.com/guide/navigation this library. Setting LinearPRogressIndicator with these showAnimationBehavior/hideAnimationBehavior, when the fragment is set as "start fragment" in graph i can see the progress indicator, instead as another destination the LinearProgressIndicator is not showed

pekingme commented 3 years ago

Thanks for clarification, @alessandroToninelli. I have made a simple app with two fragments. The LinearProgressIndicator with showAnimationBehavior and hideAnimationBehavior not none on the second fragment (non-start fragment) is animated and shown correctly. Could you verify it with the latest snapshot version? It may be affected/fixed by some recent commits. If it persists, could you provide a simple sample app which can reproduce the bug? Thanks.

alessandroToninelli commented 3 years ago

I found the mistake. Using the "androidx.fragment: fragment-ktx" library with version 1.3.0-rc01 the progress bar is not displayed in the second fragment and when go back to the "home fragment" the progress bar does not appear anymore. Using the stable version 1.2.5 instead the app works correctly and the progress bar is displayed in both fragments

wbervoets commented 3 years ago

I can confirm that adding app:showAnimationBehavior="outward" with app dependency Fragment 1.3.0-rc02 does not show the LinearProgressIndicator. Removing the app:showAnimationBehavior="outward" or downgrading to Fragment 1.2.5 solves the issue for me

Lydone commented 3 years ago

By the way, setting animation programmatically indicator.showAnimationBehavior = LinearProgressIndicator.SHOW_INWARD instead of doing this in xml file solves the issue

alessandroToninelli commented 3 years ago

but my goal was not to do it programmatically. my goal was to include it in every single xml file when I need it without writing any line of code and managing the visibility with BindingAdapters.

<com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/progressBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:indeterminate="true"
            app:showHide="@{status == Status.LOADING}"
            app:indicatorDirectionLinear="leftToRight"
            app:showAnimationBehavior="inward"
            app:hideAnimationBehavior="outward"
            />

Anyway I accept the answers thanks, I hope it will be resolved one day

spegoraro commented 3 years ago

I'm also seeing this on 1.3.0 (non-RC) however setting it programmatically isn't working either. Removing all of the showAnimationBehavior and hideAnimationBehavior allows the indicator to appear.

grad1e commented 3 years ago

Having the same issue as @spegoraro . I also had to include android:translationZ="1dp" to make it show up sometimes