界面需要,找到了一種不需要去設置android:windowSoftInputMode屬性的解決keyboard和layout不適問題
有關設置android:windowSoftInputMode的資料,可自行百度。
我的方法就是,將xml文件的根布局設置成ScrollView,將之前的布局嵌套在里面就行了,不需要去設置以上的任何屬性
在中間沒有控件顯示的地方,使用view設置weight去占位置
下面給出我的xml布局
<ScrollView 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:fillViewport="true" tools:context="com.example.richedit.TestInputMethodActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="40dp" android:background="#332423"> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="54dip" android:background="@android:drawable/bottom_bar"> <Button android:id="@+id/manual_setup" android:text="zuozuo" android:layout_height="wrap_content" android:layout_width="wrap_content" android:minWidth="100dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" /> <Button android:id="@+id/next" android:text="youyou" android:layout_height="wrap_content" android:layout_width="wrap_content" android:minWidth="100dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" /> </RelativeLayout> </LinearLayout> </ScrollView>
這里給出keyb彈出時和沒彈出時的效果圖,很好的將底部欄頂了上去