c# - 键盘出现时 UI 卷起 - MAUI

标签 c# maui

这是我对 xaml 的定义:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Entry Placeholder="Write text..."/>
    <Button Text="Button" Grid.Row="1" VerticalOptions="End" />
</Grid>

当我单击控件输入时,键盘可见。我的界面已卷起:

enter image description here

我可以通过从 RowDecinition Height 中删除所有星星来修复此问题,但严格设置该值会导致它无法适应所有屏幕。

键盘可见时是否可以关闭卷起界面?

最佳答案

在 MainActivity.cs 中:

protected override void OnCreate(Bundle savedInstanceState)
{
...
App.Current.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Pan);

...
}

关于c# - 键盘出现时 UI 卷起 - MAUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75359287/

相关文章:

c# - 如何在 MAUI 应用程序中创建自定义 TabBar?

c# - 从 OxyPlot 散点图中获取数据点

c# - 我们可以从 Apache Cordova 调用 C# Library dll 吗?

c# - 如何在 EntityFramework 4 中保存子实体?

c# - 如何在 XML 中表示\r 或\n 或\t 并使用 XmlDocument 正确读回它们

c# - 如何将属性绑定(bind)到 MAUI 中的 View 模型?

maui - 使用 DI 时无法加载资源字典

xamarin - 指定的子项已有父项。您必须先对 child 的 parent 调用 removeView()。”面对这个问题

c# - `Failed resolution of: Lcom/google/android/datatransport/TransportFactory` 使用 Xamarin.Firebase 时

c# - 你如何在 xaml 的 ListView 中拉伸(stretch)图像?