Search code examples
xamarin.formsandroid-toolbarapp-shell

Remove padding/margin on Xamarin Forms AppShell titlebar (toolbar)


I've been banging my head against a wall trying to figure this out using all kinds of fixes i found on SO and other sites but to no avail...

I'm using AppShell and I can't get the padding/margin next to the hamburger button to go away.

toolbar padding/margin

As you can see, next to the hamburger button there is extra padding or margin but i don't think it belongs to the TitleView (the black is a view that i use, it's black to show the boundaries).

OnCreate function

In my OnCreate function i already have the ToolbarResource = Resource.Layout.Toolbar;

Toolbar.xml

In Toolbar.xml i added xmlns:app="http://schemas.android.com/apk/res-auto"

and app:contentInsetLeft="0dp" app:contentInsetStart="0dp" app:contentInsetStartWithNavigation="0dp" as suggested here and here but those seem to be solutions for NavigationPage, but i don't use that in AppShell.

Help would be much appreciated!

Edit: I created a CustomRenderer for the AppShell to see if that would make a difference.

Used functions

breakpoint

but as you can see only the ContentInsetEndWithActions and ContentInsetStartWithNavigation actually get set to 0. The other ones remain 32 so they obviously ignore the Toolbar.xml.


Solution

  • I found the solution:

    In the MainActivity replace this code: enter image description here

    this in combination with the CustomRenderer made it work finally...