如何解决软键盘弹出引起的各种不
展开全部
在做登录和注册页面的时候,经常会遇到诸如软键盘挡住输入框的情况,android为此提供了一系列的的配置参数供选择,你可以在androidmanufist.xml的对应Activity的windowSoftInputMode属性中选择如下4者之一进行配置(紫色字):
int SOFT_INPUT_ADJUST_NOTHING
Adjustment option for softInputMode:
set to have a window not adjust for a shown input method.
int SOFT_INPUT_ADJUST_PAN
Adjustment option for softInputMode:
set to have a window pan when an input method is shown, so it doesn't need to deal with resizing but just panned by
the framework to ensure the current input focus is visible.
int SOFT_INPUT_ADJUST_RESIZE
Adjustment option for softInputMode:
set to allow the window to be resized when an input method is shown, so that its contents are not covered by the input method.
int SOFT_INPUT_ADJUST_UNSPECIFIED
Adjustment option for softInputMode:
nothing specified.
<activity android:name=".LoginAc"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
四个参数意思如下:
SOFT_INPUT_ADJUST_NOTHING: 不调整(输入法完全直接覆盖住,未开放此参数)
SOFT_INPUT_ADJUST_PAN: 把整个Layout顶上去露出获得焦点的EditText,不压缩多余空间,见图1
SOFT_INPUT_ADJUST_RESIZE: 整个Layout重新编排,重新分配多余空间,见图2
SOFT_INPUT_ADJUST_UNSPECIFIED: 系统自己根据内容自行选择上两种方式的一种执行(默认配置)
这里的多余空间指的是控件们通过weight分配机制得到的额外空间。
int SOFT_INPUT_ADJUST_NOTHING
Adjustment option for softInputMode:
set to have a window not adjust for a shown input method.
int SOFT_INPUT_ADJUST_PAN
Adjustment option for softInputMode:
set to have a window pan when an input method is shown, so it doesn't need to deal with resizing but just panned by
the framework to ensure the current input focus is visible.
int SOFT_INPUT_ADJUST_RESIZE
Adjustment option for softInputMode:
set to allow the window to be resized when an input method is shown, so that its contents are not covered by the input method.
int SOFT_INPUT_ADJUST_UNSPECIFIED
Adjustment option for softInputMode:
nothing specified.
<activity android:name=".LoginAc"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
四个参数意思如下:
SOFT_INPUT_ADJUST_NOTHING: 不调整(输入法完全直接覆盖住,未开放此参数)
SOFT_INPUT_ADJUST_PAN: 把整个Layout顶上去露出获得焦点的EditText,不压缩多余空间,见图1
SOFT_INPUT_ADJUST_RESIZE: 整个Layout重新编排,重新分配多余空间,见图2
SOFT_INPUT_ADJUST_UNSPECIFIED: 系统自己根据内容自行选择上两种方式的一种执行(默认配置)
这里的多余空间指的是控件们通过weight分配机制得到的额外空间。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询