"adjustResize"android
The activity's main window is always resized to make room for the soft keyboard on screen. Activity主窗口會縮小本身的顯示空間,騰出鍵盤的位置。
"adjustPan"less
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window. Activity主窗口不會縮小本身的顯示空間,而是會移動內部佈局(部分佈局被移出界面),使當前焦點不被鍵盤遮擋,用戶能夠看到輸入內容。 一般都用adjustResize,少用adjustPan,由於用戶須要關閉鍵盤,才能再和被移除的佈局進行交互。
沒有滾動控件的佈局默認屬性爲adjustPan 有滾動控件的佈局默認屬性爲adjustResize佈局
佈局文件code
<?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:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.df.softinputdemo.MainActivity"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="Hello World!"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="1" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="2" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="3" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="4" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="5" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="6" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="7" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="8" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="9" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="10" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="11" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="12" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="13" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="14" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="15" /> </LinearLayout> </ScrollView> </LinearLayout>
截圖:第一張爲打開界面截圖,第二張爲點擊第10個EditText截圖xml
一、沒有滾動控件(ScrollView)的佈局圖片
1)設置爲adjustPan
2)設置爲adjustResize
二、有滾動控件(ScrollView)的佈局utf-8
1)設置爲adjustPan
2)設置爲adjustResize