.NET MAUI Android 键盘弹起页面缩放解决方案
问题
Android 键盘弹起时,页面不缩放,输入框被遮挡。
解决方案
1. 修改 App.xaml
android:Application.WindowSoftInputModeAdjust="Resize"
<?xml version="1.0" encoding="UTF-8"?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
android:Application.WindowSoftInputModeAdjust="Resize"
x:Class="YourNamespace.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
2. 页面配置
ContentPage.SafeAreaEdges="All"
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
ContentPage.SafeAreaEdges="All"
x:Class="YourNamespace.WebViewPage">
<WebView Source="index.html" />
</ContentPage>