加了adjustPan属性后

布局直接顶上去了。。顶到了状态栏 没有顶到这里

Android 输入法弹出调整布局adjustResize不生效问题_System

非常让我们家的产品看不过去。。

所以改下

 

 

 

父布局包裹

import android.content.Context;
import android.graphics.Insets;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.WindowInsets;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

public class LinearLayoutFitSystem extends LinearLayout {
public LinearLayoutFitSystem(Context context) {
super(context);
}

public LinearLayoutFitSystem(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public LinearLayoutFitSystem(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected boolean fitSystemWindows(Rect insets) {
insets.top = 0;
return super.fitSystemWindows(insets);
}
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
Insets b = null;
b = Insets.of(0, -insets.getSystemWindowInsets().top
, 0, 0);
//使两个inset.top字段相消为0
Insets result = Insets.add(insets.getSystemWindowInsets(), b);
WindowInsets.Builder builder=new WindowInsets.Builder(insets).setSystemWindowInsets(result);
return super.dispatchApplyWindowInsets(builder.build());
}
return super.dispatchApplyWindowInsets(insets);
}

}

Android 输入法弹出调整布局adjustResize不生效问题_ide_02

清单文件配置

<activity
android:name=".FeedbackActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />