[Android布局会在键盘可见的情况下被压缩

问题描述 投票:0回答:2

我正在使用Xamarin开发Android布局。当键盘可见时,布局将被压缩。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:weightSum="20"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:background="@drawable/faded_div"/>

    <LinearLayout
        android:id="@+id/div1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:gravity="center_vertical"/>

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="16"
        android:orientation="vertical"/>

    <RelativeLayout
        android:id="@+id/div2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2">

        <Common.Droid.UI.Controls.NXButton
            android:layout_height="44dp"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"
            android:text="Aplicar"/>
    </RelativeLayout>

</LinearLayout>

目标是让键盘覆盖布局。

当键盘可见时,如何防止屏幕移动?你能帮我吗?

android xamarin xamarin.android
2个回答
0
投票

xamarin native andorid中,请在Activity上使用以下语法代码以防止屏幕移动:

Window.SetSoftInputMode(SoftInput.AdjustNothing);

0
投票

测试

<activity android:name=".UserRegistration"
    android:windowSoftInputMode="adjustNothing">

测试后告诉我结果

© www.soinside.com 2019 - 2024. All rights reserved.