簡體   English   中英

如果鍵盤可見,Android 布局將被壓縮

[英]Android layout get compressed if keyboard is visible

我正在使用 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>

目標是讓鍵盤覆蓋布局。

當鍵盤可見時,如何防止屏幕移動? 你能幫助我嗎?

xamarin native andorid中,在您的Activity上使用此語法代碼來防止屏幕移動:

Window.SetSoftInputMode(SoftInput.AdjustNothing);

測試一下

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

測試后告訴我結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM