簡體   English   中英

出現鍵盤時布局受到擠壓

[英]Layout is squeezing when keyboard appears

鍵盤彈出時,我的布局有些壓縮。 這是我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:focusable="true"
    android:focusableInTouchMode="true">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="10"
        android:background="@android:color/white">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:weightSum=".9"
            android:layout_weight="2"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_weight=".01" />
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_weight=".3"
                android:paddingLeft="12dp"
                android:id="@+id/username"
                android:hint="@string/username"
                android:textColorHint="@color/edittextcolor"/>

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="10dp"
                android:hint="@string/password"
                android:layout_weight=".3"
                android:paddingLeft="12dp"
                android:textColorHint="@color/edittextcolor"
                android:layout_marginRight="10dp"
                android:id="@+id/password" />

         </LinearLayout>

         <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight=".7"
                android:weightSum="2"
                android:layout_marginTop="30dp">

            <Button
                android:id="@+id/signup"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/Sign"
                android:textColor="@android:color/white"
                android:layout_marginLeft="20dp" />

            <Button
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/login"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:textColor="@android:color/white" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="4" >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

當鍵盤不出現時,布局看起來不錯。我在mainifest文件中添加了android:windowSoftInputMode =“ adjustResize”。但仍然無法正常工作。 任何幫助將不勝感激。謝謝。

更改

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" 
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:weightSum="10"
 android:background="@android:color/white">

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

希望您的問題得到解決。

暫無
暫無

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

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