Fix mobile panel safe area
This commit is contained in:
1 parent
41405bcc4f
commit
b388711dcf
4 files changed
+40
-3
No files matched your search
@@ -4,6 +4,8 @@ using Android.Content.PM;
|
||||
using Android.Database;
|
||||
using Android.OS;
|
||||
using Android.Provider;
|
||||
using Android.Views;
|
||||
using AndroidX.Core.View;
|
||||
using LMEMappeCatastaliApp.Services;
|
||||
|
||||
namespace LMEMappeCatastaliApp;
|
||||
@@ -24,9 +26,18 @@ public class MainActivity : MauiAppCompatActivity
|
||||
protected override void OnCreate(Bundle? savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
ApplySystemBarInsets();
|
||||
QueueViewedFile(Intent);
|
||||
}
|
||||
|
||||
private void ApplySystemBarInsets()
|
||||
{
|
||||
var content = FindViewById<Android.Views.View>(Android.Resource.Id.Content);
|
||||
if (content is null) return;
|
||||
ViewCompat.SetOnApplyWindowInsetsListener(content, new SystemBarInsetsListener(content));
|
||||
ViewCompat.RequestApplyInsets(content);
|
||||
}
|
||||
|
||||
protected override void OnNewIntent(Intent? intent)
|
||||
{
|
||||
base.OnNewIntent(intent);
|
||||
@@ -72,4 +83,19 @@ public class MainActivity : MauiAppCompatActivity
|
||||
var index = cursor.GetColumnIndex(IOpenableColumns.DisplayName);
|
||||
return index >= 0 ? cursor.GetString(index) : null;
|
||||
}
|
||||
|
||||
private sealed class SystemBarInsetsListener(Android.Views.View content) : Java.Lang.Object, IOnApplyWindowInsetsListener
|
||||
{
|
||||
private readonly int _left = content.PaddingLeft;
|
||||
private readonly int _top = content.PaddingTop;
|
||||
private readonly int _right = content.PaddingRight;
|
||||
|
||||
public WindowInsetsCompat? OnApplyWindowInsets(Android.Views.View? view, WindowInsetsCompat? insets)
|
||||
{
|
||||
if (view is null || insets is null) return insets;
|
||||
var systemBars = insets.GetInsets(WindowInsetsCompat.Type.SystemBars());
|
||||
view.SetPadding(_left, _top, _right, systemBars?.Bottom ?? 0);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user