Fullscreen custom renderer for Android

ErlendAErlendA NOMember ✭✭

I want some content pages to have a transparent background on the navigation bar (toolbar on Android). Since I only need this for a few pages in the app I created a custom renderer: FullscreenPageRenderer.

public class FullscreenPageRenderer : PageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
Activity parent = (Activity)Context;
var toolbar = parent.FindViewById(Resource.Id.toolbar);
toolbar.Background = new ColorDrawable(Color.Transparent.ToAndroid());
parent.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
parent.Window.AddFlags(WindowManagerFlags.Fullscreen);
ViewGroup.ForceLayout();
}
}

I want it to look like this image

After setting this properties in my renderer I still get a behavior where my page content is placed beneath the toolbar and not underneath it.
Any suggestions to this is greatly appreciated.

Answers

Sign In or Register to comment.