输入法挤压布局问题

90,正解

 

Android中弹出输入法界面不影响app界面布局
默认情况下,输入法弹出的时候,原来的view会被挤扁。有些应用不想被挤,它们可以接受被输入法view覆盖在上面。这时候需要在 AndroidManifest.xml acitivty里面加上一句: android:windowSoftInputMode="adjustPan"

 

80,其他

///

在android中开发中,经常遇到这样的问题,当你在Editext输入框要输入东西的时候,会自动调出来输入法界面,会挡住登录的EditText框,其实解决这个问题很简单,只要在Activity中输入如下的句子就行,windowSoftInputMode="adjustResize",就轻松解决了这个问题。

///

 

真心没明白你什么意思
View.VISIBLE--->可见
View.INVISIBLE--->不可见,但这个View仍然会占用在xml文件中所分配的布局空间,不重新layout
View.GONE---->不可见,但这个View在ViewGroup中不保留位置,会重新layout,不再占用空间,那后面的view就会取代他的位置,


///
http://jojol-zhou.iteye.com/blog/1299017

关于android的输入法弹出来 覆盖输入框的问题
 
android 界面中 点击输入框时 弹出输入法 如果输入框在底部 会出现输入法遮挡输入内容的问题
 
解决办法 设置activity的 window soft input mode 属性,属性具体参看google官方文档或译文(见后面)。
 
需要备注的是
1.使用adjustResize属性是 如果界面中没有滚动条 需要添加一个滚动条scrollview包裹所有内容,保证resize后 能滚动显示显示不下的内容
2.全屏fullscreen模式时 adjustResize属性失效

///

系统事件的话,是不存在广播的,如果你有自定义的RootView,可以在onMeasure里

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

// 由当前布局被键盘挤压,获知,由于键盘的活动,导致布局将要发生变化。
do {
    final int width = MeasureSpec.getSize(widthMeasureSpec);
    final int height = MeasureSpec.getSize(heightMeasureSpec);

    Log.d(TAG, "onMeasure, width: " + width + " height: " + height);
    if (height < 0) {
        break;
    }
    if (mOldHeight < 0) {
        mOldHeight = height;
        break;
    }
    final int offset = mOldHeight - height;
    mOldHeight = height;
    if (offset == 0) {
        Log.d(TAG, "" + offset + " == 0 break;");
        break;
    }
    // 检测到真正的 由于键盘收起触发了本次的布局变化
    if (offset > 0) {
        //键盘弹起 (offset > 0,高度变小)
    } else {
        //键盘收回 (offset < 0,高度变大)
    }
} while (false);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}

或者也可以设置监听事件
rootView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
if (mOriginalLayoutParams == null) {
mOriginalLayoutParams = (RelativeLayout.LayoutParams) mActionPanelView.getLayoutParams();
}
Rect r = new Rect();
View view = rootWindow.getDecorView();
view.getWindowVisibleDisplayFrame(r);

                    int bottom = r.bottom;
                    if (bottom == mLastBottom) {
                        return;
                    }
                    mLastBottom = bottom;
                    if (bottom > mBottomWhenKeyboardHidden) {
                        mBottomWhenKeyboardHidden = bottom;
                    }

                    if (bottom < mBottomWhenKeyboardHidden) {
                        // 键盘弹出
                    } else {
                        // 键盘收起
                    }
                }
            });
}


///

 1 android:scrollbars="vertical"
2 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);


///

1
2
3
4
    
在AndroidManifest里面配置Activity的属性
 
            android:windowSoftInputMode="adjustUnspecified|stateHidden"
            android:configChanges="orientation|keyboardHidden"

///


 

posted @ 2015-12-29 20:22  Augustone  阅读(265)  评论(0)    收藏  举报