Ripple effect colors

Yegor 0 Reputation points
2023-04-24T19:31:38.42+00:00

Is there any way to change the colors of the ripple effect on the buttons?

Developer technologies | .NET | .NET MAUI
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2023-04-25T06:18:29.0333333+00:00

    Hello,

    Is there any way to change the colors of the ripple effect on the buttons?

    Yes. This ripple effect for button just happens on the android platform, you can use MAUI Handler to change it, you can refer to following code. I change color of ripple to Green for testing. By the way, if you want to remove the ripple effect like other platforms, you can set the color to transparent.

        Microsoft.Maui.Handlers.ButtonHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
            {
    #if ANDROID
                if (handler.PlatformView.Background is Android.Graphics.Drawables.RippleDrawable ripple )
                {
                    ripple.SetColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Green));
                };
    #endif
            });
    

    Best Regards, Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Anonymous
    2023-04-27T01:09:41.5866667+00:00

    edit delete

    0 comments No comments

  3. Gulam Ali Hakim 0 Reputation points
    2024-02-15T18:27:47.74+00:00

    The easiest way to add native click effects on .NET MAUI https://github.com/FreakyAli/Maui.FreakyEffects

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.