重点代码:
using Xamarin.Forms; using Xamarin.Forms.PlatformConfiguration; using Xamarin.Forms.PlatformConfiguration.AndroidSpecific; using Xamarin.Forms.Xaml; namespace JKSY.Views { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class LoginView : ContentPage { public LoginView() { InitializeComponent(); } protected override void OnAppearing() { base.OnAppearing(); Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize); } protected override void OnDisappearing() { base.OnDisappearing(); Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Pan); } } }
参考:
https://*.com/questions/49122731/xamarin-android-windowsoftinput-resize-specific-page