The android pop-up input method soft keyboard squeezes the screen or squeezes the control problem

Without further ado, let's go straight to the solution.
in AndroidManifest.xml

Add android:windowSoftInputMode="adjustPan|stateHidden" to the activity

<activity android:name=".SelectMoShiActivity"  android:windowSoftInputMode="adjustPan|stateHidden"/>

Perfect solution.

The principle is as follows (don't look, waste time)
in the Android official document defines the setSoftInputMode (int mode) method as follows:

    /**
     * Specify an explicit soft input mode to use for the window, as per
     * {@link WindowManager.LayoutParams#softInputMode
     * WindowManager.LayoutParams.softInputMode}.  Providing anything besides
     * "unspecified" here will override the input mode the window would
     * normally retrieve from its theme.
     */
    public void setSoftInputMode(int mode) {
    
    
        final WindowManager.LayoutParams attrs = getAttributes();
        if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
    
    
            attrs.softInputMode = mode;
            mHasSoftInputMode = true;
        } else {
    
    
            mHasSoftInputMode = false;
        }
        dispatchWindowAttributesChanged(attrs);
    }

Other commonly used soft keyboard input method modes include:

//软键盘的状态并没有指定,系统将选择一个合适的状态或依赖于主题的设置
public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;

//当这个activity出现时,软键盘将一直保持在上一个activity里的状态,无论是隐藏还是显示
public static final int SOFT_INPUT_STATE_UNCHANGED = 1;

//用户选择activity时,软键盘总是被隐藏
public static final int SOFT_INPUT_STATE_HIDDEN = 2;

//当该Activity主窗口获取焦点时,软键盘也总是被隐藏的
public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;

//软键盘通常是可见的
public static final int SOFT_INPUT_STATE_VISIBLE = 4;

//用户选择activity时,软键盘总是显示的状态
public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;

//默认设置,通常由系统自行决定是隐藏还是显示
public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;

//该Activity总是调整屏幕的大小以便留出软键盘的空间
public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;

//当前窗口的内容将自动移动以便当前焦点从不被键盘覆盖和用户能总是看到输入内容的部分
public static final int SOFT_INPUT_ADJUST_PAN = 0x20;

Guess you like

Origin blog.csdn.net/sun6223508/article/details/128928977