Bug 58277 - [Android] Button's shadow clipped when inside layout
Summary: [Android] Button's shadow clipped when inside layout
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.5
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-20 18:31 UTC by Luccas Clezar
Modified: 2018-04-10 16:52 UTC (History)
4 users (show)

Tags: ac android button shadow clipping fr
Is this bug a regression?: ---
Last known good build:


Attachments
The leftmost part of the Button (left: without "workaround", right: with "workaround") (1.38 KB, image/png)
2017-07-20 18:31 UTC, Luccas Clezar
Details
repro project (43.75 KB, application/zip)
2017-07-21 22:52 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Luccas Clezar 2017-07-20 18:31:49 UTC
Created attachment 23700 [details]
The leftmost part of the Button (left: without "workaround", right: with "workaround")

I'm experiencing a (very) strange bug where shadows from elevation (on Android) get clipped.

I really can't detail more than that because there are pages in my app that this happens, but there are others similar pages that are normal.  

To reproduce, just create a page with this UI:

    var buttonLayout = new Grid
    {
        RowDefinitions =
        {
            new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }
        },
        RowSpacing = 12,
        Padding = new Thickness(16)
    };

    buttonLayout.AddChild(new Button { BackgroundColor = Color.FromHex("#ffffff"), Text = "Button1" }, 0, 0);
    Content = buttonLayout;

The default Button has some padding, so you'll have to click it to see the clipping.

The strange part is that, if I add an invisible layout to the root layout, the clipping is gone (see attachment), like this:

    var buttonLayout = new Grid
    {
        RowDefinitions =
        {
            new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }
        },
        Padding = new Thickness(16)
    };

    buttonLayout.Children.Add(new Grid { IsVisible = false }, 0, 0);

    buttonLayout.AddChild(new Button { BackgroundColor = Color.FromHex("#ffffff"), Text = "Button1" }, 0, 0);
    Content = buttonLayout;

I tested this bug on Android 6.0 and 7.1 with the last Xamarin.Forms stable (2.3.4.247) and pre-release (2.3.5.256-pre6).
Comment 1 Jimmy [MSFT] 2017-07-21 22:52:33 UTC
Created attachment 23728 [details]
repro project

I created a new sample project and I am seeing this issue as well. Press and hold the Button so the shadow can grow and it will be clipped.

I also tested this with 2.3.5-pre6 and 2.3.6.120-nightly. Those versions use the Button fast renderer by default which has the known issue of missing the shadow, however I can still reproduce the issue after configuring it to use the old renderer.
Comment 2 sh.naz 2017-08-24 10:33:08 UTC
We are also experiencing this issue. 
The workaround with invisible empty view works. I hope this is resolved so we dont have to add empty invisible views everywhere.
Comment 3 Samantha Houts [MSFT] 2018-04-10 16:52:36 UTC
I believe this should be resolved in 2.5.1. If you are still experiencing problems, please open a new ticket on GitHub (https://github.com/xamarin/Xamarin.Forms/issues/new). Thank you!


https://github.com/xamarin/Xamarin.Forms/pull/1570