Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression/8.0.0-preview.6.8686] Button Click Ripple Effect Not Working In Android #17642

Closed
welcometochristown opened this issue Sep 26, 2023 · 10 comments · Fixed by #20412
Closed
Assignees
Labels
area-controls-button Button, ImageButton fixed-in-8.0.20 fixed-in-9.0.0-preview.4.10690 i/regression This issue described a confirmed regression on a currently supported version migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 t/bug Something isn't working
Milestone

Comments

@welcometochristown
Copy link

welcometochristown commented Sep 26, 2023

Description

The button click animation does not work in my Android app .Net8 for Maui, but does work in .Net7

Using the default project for both, only in .Net7 can I see the little fade animation when I press the button.

.net8
270119662-96f25308-a7fd-4e68-84d1-9e2d4c16960b

.net7
270119657-02bf0055-bd42-4d04-9cba-945a393659e5

From what I have gathered the .net 7, the button's android platform view's background value is an instance of the RippleDrawable Class. And In the .net 8, it's an instance of the BorderDrawable Class.

Steps to Reproduce

Create Default Maui application (Using .Net 8)
Run default application on android.
Click counter button.

Link to public reproduction project repository

No response

Version with bug

8.0.0-preview.6.8686

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.0-preview.5.8529

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@welcometochristown welcometochristown added the t/bug Something isn't working label Sep 26, 2023
@drasticactions
Copy link
Contributor

I believe this is a sideeffect of #15725, but I'm not sure if it's a bug or intentional.

The background color is set as part of the default MAUI styles, to a solid color. The newer behavior in main/net8.0 is to update the background brush with the correct brush style, which, I think, removes RippleDrawable, where before it would have just replaced the literal color on the same background type.

If you remove the default MAUI Styles (or just remove the ones for button) the ripple should return, since that background color is no longer being set. The default button used by MAUI is a MaterialButton which does include that effect by default, AFAIK.

@jsuarezruiz does this sound right? What do you think?

@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Sep 26, 2023
@samhouts samhouts added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Sep 26, 2023
@samhouts samhouts added this to the .NET 8 GA milestone Sep 26, 2023
@samhouts samhouts changed the title Button Click Ripple Effect Not Working In Android .Net 8 [regression/8.0.0] Button Click Ripple Effect Not Working In Android Sep 26, 2023
@welcometochristown
Copy link
Author

welcometochristown commented Sep 28, 2023

I believe this is a sideeffect of #15725, but I'm not sure if it's a bug or intentional.

The background color is set as part of the default MAUI styles, to a solid color. The newer behavior in main/net8.0 is to update the background brush with the correct brush style, which, I think, removes RippleDrawable, where before it would have just replaced the literal color on the same background type.

If you remove the default MAUI Styles (or just remove the ones for button) the ripple should return, since that background color is no longer being set. The default button used by MAUI is a MaterialButton which does include that effect by default, AFAIK.

@jsuarezruiz does this sound right? What do you think?

@drasticactions Removing the BackgroundColor property in the default MAUI styles does indeed add back the ripple effect.

This does however mean that I can't use the BackgroundColor property on the button and instead used a handler to set the background color back to white.

#if ANDROID
            Microsoft.Maui.Handlers.ButtonHandler.Mapper.AppendToMapping("WhiteBackground", (handler, view) =>
            {
                var button = view.Handler.PlatformView as AndroidX.AppCompat.Widget.AppCompatButton;
                button.SetBackgroundColor(Android.Graphics.Color.White);
            });
#endif

This obviously makes it a little tricky if I have many buttons that require different background colors.

@jsuarezruiz jsuarezruiz self-assigned this Sep 28, 2023
@samhouts samhouts added i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Sep 28, 2023
@samhouts
Copy link
Member

Confirmed that this regressed between 8.0.0-preview.5.8529 and 8.0.0-preview.6.8686. Like @drasticactions indicated, likely caused by #15725. We're now always setting the Drawable to the PaintDrawable instead of using the RippleDrawable.

@samhouts samhouts changed the title [regression/8.0.0] Button Click Ripple Effect Not Working In Android [regression/8.0.0-preview.6.8686] Button Click Ripple Effect Not Working In Android Sep 28, 2023
@PureWeen PureWeen modified the milestones: .NET 8 GA, .NET 8 SR1 Sep 28, 2023
@PureWeen PureWeen modified the milestones: .NET 8 SR1, .NET 8 SR2 Nov 3, 2023
@PureWeen PureWeen modified the milestones: .NET 8 SR2, .NET 8 SR3 Nov 22, 2023
@samhouts samhouts moved this from Todo to In Progress in MAUI SDK Ongoing Dec 21, 2023
@zippo227
Copy link

Avoiding the set of the background color hasn't helped me so far. Glad to see this is being worked on.

@bcaceiro
Copy link

This is actually important, since the effect from Touch is essential in ui/ux of mobile applications...

@DeepWorksStudios
Copy link

If you set an background to the button than the bug accures too in the lastest version 8.0.6

@adelmurad24
Copy link

Still not works with .net8, and yest works normally with .net7 ...............

@prabhavmehra
Copy link

I see the same issue for iOS as well.

@PureWeen PureWeen moved this from In Progress to To Move in MAUI SDK Ongoing Feb 28, 2024
@PureWeen PureWeen moved this from To Move to In Progress in MAUI SDK Ongoing Mar 5, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR3, .NET 8 SR4 Mar 5, 2024
@PureWeen PureWeen added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Mar 11, 2024
@m1dst
Copy link

m1dst commented Mar 11, 2024

#18857 was closed as a dupe of this however that issue also mentioned padding issues and this issue does not. Please ensure the padding is also resolved as that is the part I'm interested in.

@lhfwc
Copy link

lhfwc commented Mar 12, 2024

Same for us, paddings don't work on Android. As far as I can see avoiding "BackgroundColor" does not resolve the issue.

@PureWeen PureWeen assigned mattleibow and unassigned jsuarezruiz Apr 2, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Apr 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-button Button, ImageButton fixed-in-8.0.20 fixed-in-9.0.0-preview.4.10690 i/regression This issue described a confirmed regression on a currently supported version migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 t/bug Something isn't working
Projects
Status: Done