这是一个布局:
<RelativeLayout 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" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" /> <FrameLayout android:background="#0000ff" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" /> <FrameLayout android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" /> </LinearLayout> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> </RelativeLayout>
当触摸EditText并出现软键盘时,我希望蓝条保持不变.即我希望保留它的大小和位置.我在AndroidManifest中为我的activity的参数android:windowSoftInputMode尝试了所有四个可能的值.总是我的蓝色条在软键盘上移动或缩小:
android:windowSoftInputMode =“adjustUnspecified”或默认情况下:
android:windowSoftInputMode =“adjustPan”或android:windowSoftInputMode =“adjustnothing”:
机器人:windowSoftInputMode = “adjustResize”:
当软键出现时,它是否可以保持相同的大小和位置?
解决方法
由于输入进入你的EditText,它总是会移动一些东西.
考虑使用两种布局,一种用于键盘关闭时,一种用于键盘启动时.
使用ViewSwitcher可能会有所帮助.