1
這是我的應用程序,當軟鍵盤被隱藏時 但是當顯示鍵盤時,頂部的edittext框消失了(它被向上推)。 它看起來像這樣。顯示鍵盤時的佈局問題
我的問題是如何在顯示鍵盤時保持編輯框可見?我想只有在編輯框中之間的空間被縮小...但兩個框是可見的
我的佈局到目前爲止是這樣
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:id="@+id/relativeLayout1">
<EditText android:id="@+id/editText1" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_width="fill_parent">
<requestFocus></requestFocus>
</EditText>
<EditText android:id="@+id/editText2" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_width="fill_parent"></EditText>
<ImageView android:id="@+id/imageView1"
android:layout_height="wrap_content" android:layout_below="@id/editText1"
android:layout_above="@id/editText2" android:background="@drawable/icon"
android:layout_width="fill_parent"></ImageView>
</RelativeLayout>
在我的清單中,我把android:windowSoftInputMode =「stateVisible | adjustResize」,它的工作原理,但你可以給我一個簡短的解釋是什麼,這是可以改變代碼? – Lukap
Android會嘗試爲您處理視圖,以確保您輸入的字段不會被鍵盤隱藏。有很多方法可以做到這一點。平移只是移動整個視圖,直到您可以看到該字段。調整大小調整整個視圖以佔用未被鍵盤隱藏的空間,這正是您想要的。我知道無法在代碼中設置它,但可能有一個地方。儘管在xml中設置它是標準的。 –