Android 上的软键盘输入模式Soft Keyboard Input Mode on Android
07/10/2018
本文内容
This Android platform-specific is used to set the operating mode for a soft keyboard input area, and is consumed in XAML by setting the Application.WindowSoftInputModeAdjust attached property to a value of the WindowSoftInputModeAdjust enumeration:
xmlns:android="clr-namespace::::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific;assembly=:::no-loc(Xamarin.Forms):::.Core"
android:Application.WindowSoftInputModeAdjust="Resize">
...
此外,还可以使用 Fluent API 从 c # 使用该方法:Alternatively, it can be consumed from C# using the fluent API:
using :::no-loc(Xamarin.Forms):::.PlatformConfiguration;
using :::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific;
...
App.Current.On().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
Application.On方法指定此平台特定的仅在 Android 上运行。The Application.On method specifies that this platform-specific will only run on Android. [ Application.UseWindowSoftInputModeAdjust ] (x: :::no-loc(Xamarin.Forms)::: 。PlatformConfiguration. UseWindowSoftInputModeAdjust (:::no-loc(Xamarin.Forms)::: 。IPlatformElementConfiguration { :::no-loc(Xamarin.Forms)::: 。PlatformConfiguration :::no-loc(Xamarin.Forms)::: 。应用程序}, :::no-loc(Xamarin.Forms)::: 。PlatformConfiguration. AndroidSpecific. WindowSoftInputModeAdjust) # A3 方法在 :::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific 命名空间中,用于设置软键盘输入区域的运行模式, WindowSoftInputModeAdjust 枚举提供了两个值: Pan 和 Resize 。Pan该值使用 AdjustPan 调整选项,该选项不会在输入控件具有焦点时调整窗口的大小。The Pan value uses the AdjustPan adjustment option, which doesn't resize the window when an input control has focus. 相反,窗口的内容是平移的,因此不会由软键盘遮盖当前焦点。Instead, the contents of the window are panned so that the current focus isn't obscured by the soft keyboard. Resize该值使用 AdjustResize 调整选项,该选项可在输入控件有焦点的情况下调整窗口的大小,以便为软键盘腾出空间。The Resize value uses the AdjustResize adjustment option, which resizes the window when an input control has focus, to make room for the soft keyboard.
结果是,当输入控件具有焦点时,可以设置软键盘输入区域操作模式:The result is that the soft keyboard input area operating mode can be set when an input control has focus:
相关链接Related links