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

Maui Android parent view inappropriately creates clipping mask when its opacity is less than 1, cropping out children #22038

Open
jonmdev opened this issue Apr 24, 2024 · 1 comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@jonmdev
Copy link

jonmdev commented Apr 24, 2024

Description

If you (1) set up a simple hierarchy with an AbsoluteLayout as parent, (2) add some random views as its children, (3) set some small dimensions of the AbsoluteLayout, then (4) set the AbsoluteLayout's opacity <1, behavior is abnormal in Android:

  • Windows: Still can see all children at reduced opacity (expected behavior):
    android opacity bug windows

  • Android: AbsoluteLayout develops a clipping mask and crops out all children to dimensions of AbsoluteLayout setting (wrong behavior):
    android opacity bug android

In the example above we have a plain AbsoluteLayout with a red Border, cat Image, and simple "HELLO" Label as children.

In Windows we see all children fully at reduced opacity as expected.

In Android everything gets clipped out to the sliver of the AbsoluteLayout's small dimensions (wrong behavior).

I am currently unable to test iOS so don't know what that would do.

Steps to Reproduce

All code is in App.xaml.cs (otherwise using default Maui project):

namespace AndroidOpacityBug {
    public partial class App : Application {
        public App() {

            bool SET_TRUE_TO_SEE_ANDROID_BUG = true;

            //=============
            //BUG:
            //=============
            //in Windows whether you set the above bool to true or false you will see the red border, label, and cat with reduced opacity
            //in Android if you set the above bool to true everything gets clipped out by the absolutelayout's size setting and you see nothing

            ContentPage mainPage = new();
            this.MainPage = mainPage;

            AbsoluteLayout absDummy = new();
            mainPage.Content = absDummy;

            AbsoluteLayout absRoot = new();

            if (SET_TRUE_TO_SEE_ANDROID_BUG) {
                absRoot.WidthRequest = 1;
                absRoot.HeightRequest = 50;
            }
            
            absDummy.Add(absRoot);

            Border border = new();
            border.BackgroundColor = Colors.Red;
            border.WidthRequest = border.HeightRequest = 200;
            absRoot.Add(border);

            Label label = new();
            label.Text = "HELLO";
            absRoot.Add(label);

            Image image = new();
            image.Source = ImageSource.FromResource( "AndroidOpacityBug.Resources.Images.cat.jpg");
            image.WidthRequest = image.HeightRequest = 100;
            absRoot.Add(image);
            absRoot.Opacity = 0.4;

        }
    }
}

Link to public reproduction project repository

https://github.com/jonmdev/AndroidOpacityBug

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

No, this is something new

Affected platforms

Android

@jonmdev jonmdev added the t/bug Something isn't working label Apr 24, 2024
@kevinxufei kevinxufei added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 25, 2024
@kevinxufei
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 5 (8.0.0-rc.2.9530/8.0.21). Can repro it with sample project.

@PureWeen PureWeen added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label May 31, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 4, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants