Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Can't overlay Shell FlyoutHeader on FlyoutBackgroundImage #6595

Closed
rmarinho opened this issue Jun 19, 2019 · 3 comments
Closed

[Bug] Can't overlay Shell FlyoutHeader on FlyoutBackgroundImage #6595

rmarinho opened this issue Jun 19, 2019 · 3 comments

Comments

@rmarinho
Copy link
Member

rmarinho commented Jun 19, 2019

If i set a FlyoutBackgroundImage to fill all my flyout, then want to overlay my header so it sits on top of the background image, this works fine on iOS, but on Android it renders a white background on the flyout header area and my FlyoutHeaderTemplate above, not sure if the FlyoutBackgroundImage is behind the white on the FlyoutHeader

Description

Steps to Reproduce

FloutHeaderTemplate
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SCE.Templates.FlyoutHeader"
             BackgroundColor="Transparent" >
 <Image Source="logo_sce_peq.png" >
</ContentView >

<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
       FlyoutHeaderTemplate="{StaticResource ShellFlyoutTemplate}"
       xmlns:xfh="http://xamarin.forms/schemas/helpers"
       FlyoutBackgroundImage="back.jpg"
       FlyoutBackgroundImageAspect="Fill">

Expected Behavior

Should render a transparent background , the logo png should be above the back.jpg

Actual Behavior

Renderes white background

Basic Information

  • Version with issue: master

Screenshots

Simulator Screen Shot - iPhone Xʀ - 2019-06-19 at 23 27 15

Screenshot_1560983153

Reproduction Link

@rmarinho rmarinho added t/bug 🐛 s/unverified New report that has yet to be verified labels Jun 19, 2019
@pauldipietro pauldipietro added this to New in Triage Jun 19, 2019
@rmarinho rmarinho added a/shell 🐚 p/Android e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Jun 19, 2019
@rmarinho rmarinho moved this from New to Ready For Work in Triage Jun 19, 2019
@samhouts samhouts removed this from Ready For Work in Triage Jun 27, 2019
@samhouts samhouts added this to Backlog in Shell Jan 3, 2020
@Qythyx
Copy link

Qythyx commented Jul 2, 2020

Is there any workaround for this? Even a custom renderer?

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@Qythyx
Copy link

Qythyx commented Dec 20, 2020

I finally found a work around for this using a custom renderer in Android. This works for me, hopefully it'll help others.

using Android.Content;
using BeerApp.App.Droid.CustomRenderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(Shell), typeof(CustomShellRenderer))]
namespace BeerApp.App.Droid.CustomRenderers
{
	public class CustomShellRenderer : ShellRenderer
	{
		public CustomShellRenderer(Context context) : base(context)
		{
		}

		/// <summary>
		/// This is needed due to bug (https://github.com/xamarin/Xamarin.Forms/issues/6595)
		/// in Xamarin such that setting the background color
		/// to Transparent for the content in Shell.FlyoutHeader does not work and shows some
		/// default underlying color. This sets that underlying color to Transparent.
		/// </summary>
		/// <returns>The renderer.</returns>
		protected override IShellFlyoutContentRenderer CreateShellFlyoutContentRenderer()
		{
			var renderer = base.CreateShellFlyoutContentRenderer();
			if(renderer != null) {
				var viewGroup = (Android.Views.ViewGroup)renderer.AndroidView;
				var linearLayout = (Android.Widget.LinearLayout)viewGroup.GetChildAt(0)!;
				linearLayout.SetBackgroundColor(Color.Transparent.ToAndroid());
				linearLayout.SetOutlineSpotShadowColor(Color.Transparent.ToAndroid());
			}
			return renderer!;
		}
	}
}

@PureWeen
Copy link
Contributor

PureWeen commented Feb 9, 2021

#13322

@PureWeen PureWeen closed this as completed Feb 9, 2021
Android Ready For Work automation moved this from To do to Done Feb 9, 2021
Shell automation moved this from Backlog to Done Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Shell
  
Done
Development

No branches or pull requests

5 participants