Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/redth/mauiedgetoedge
Playing around with edge to edge apps and safe areas
https://github.com/redth/mauiedgetoedge
Last synced: 23 days ago
JSON representation
Playing around with edge to edge apps and safe areas
- Host: GitHub
- URL: https://github.com/redth/mauiedgetoedge
- Owner: Redth
- License: mit
- Created: 2024-08-28T18:07:25.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-08-28T19:33:22.000Z (2 months ago)
- Last Synced: 2024-10-13T15:08:10.623Z (25 days ago)
- Language: C#
- Size: 219 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MauiEdgeToEdge
Playing around with edge to edge apps and safe areas## Android
If we enable Edge to Edge on Android in a MAUI app (built against, targeting, and _running_ on API 35), things don't quite look right:![image](https://github.com/user-attachments/assets/7f3d46cf-bd24-4e7c-b383-f7a117db5b10)
> The 'EdgeToEdge' class was ported from Kotlin code until we reference newer AndroidX packages which contain this functionality
### Fixing the MaterialToolbar on NavigationPage
It looks like we use `MaterialToolbar` nested inside an `AppBarLayout`. The `AppBarLayout` needs to be set to fit system windows in order to have the correct padding to cause content to not layout beneath the status bar:
```csharp
Microsoft.Maui.Handlers.ToolbarHandler.Mapper.AppendToMapping("FixInsets", (handler, view)=>
{
var parentView = view.Parent?.Handler?.PlatformView;if (parentView is Activity activity)
{
activity?.FindViewById(Resource.Id.navigationlayout_appbar)
?.SetFitsSystemWindows(true);
}
else if (parentView is Android.Views.View androidView)
{
androidView?.FindViewById(Resource.Id.navigationlayout_appbar)
?.SetFitsSystemWindows(true);
}
});
```