现在封装了个webview,webview加载的网页中有个编辑框,当在竖屏时点击编辑框,软键盘弹出,屏幕上移,但是当横屏时点击编辑框,这时弹出的软键盘会覆盖屏幕,屏幕不上移,请问是什么原因?由于要处理横竖切换问题重新实现了以下方法:@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// 检测屏幕的方向:纵向或横向
if (this.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
//当前为横屏, 在此处添加额外的处理代码
int flag=filewebview.getVisibility();
if(flag==View.GONE)
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=(int)screenWidth-20;
webview.setLayoutParams(linearParams);
}
else
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=webviewheight;
webview.setLayoutParams(linearParams);
}
} else if (this.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT) {
//当前为竖屏, 在此处添加额外的处理代码
int flag=filewebview.getVisibility();
if(flag==View.GONE)
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=(int)screenHeight-20;;
webview.setLayoutParams(linearParams);
}
else
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=webviewheight;
webview.setLayoutParams(linearParams);
}
} //检测实体键盘的状态:推出或者合上
if (newConfig.hardKeyboardHidden
== Configuration.HARDKEYBOARDHIDDEN_NO){
//实体键盘处于推出状态,在此处添加额外的处理代码
}
else if (newConfig.hardKeyboardHidden
== Configuration.HARDKEYBOARDHIDDEN_YES){
//实体键盘处于合上状态,在此处添加额外的处理代码
} }
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// 检测屏幕的方向:纵向或横向
if (this.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
//当前为横屏, 在此处添加额外的处理代码
int flag=filewebview.getVisibility();
if(flag==View.GONE)
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=(int)screenWidth-20;
webview.setLayoutParams(linearParams);
}
else
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=webviewheight;
webview.setLayoutParams(linearParams);
}
} else if (this.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT) {
//当前为竖屏, 在此处添加额外的处理代码
int flag=filewebview.getVisibility();
if(flag==View.GONE)
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=(int)screenHeight-20;;
webview.setLayoutParams(linearParams);
}
else
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) webview.getLayoutParams();
linearParams.height=webviewheight;
webview.setLayoutParams(linearParams);
}
} //检测实体键盘的状态:推出或者合上
if (newConfig.hardKeyboardHidden
== Configuration.HARDKEYBOARDHIDDEN_NO){
//实体键盘处于推出状态,在此处添加额外的处理代码
}
else if (newConfig.hardKeyboardHidden
== Configuration.HARDKEYBOARDHIDDEN_YES){
//实体键盘处于合上状态,在此处添加额外的处理代码
} }
输入法内部重新实现了
onEvaluateFullscreenMode 方法
boolean onEvaluateFullscreenMode(){
return ture;
}
这样只要横屏,输入法就会全屏显示了。