经常碰到 记录一下
最外层的布局实现
private int[] mInsets = new int[4];
@Override
protected final boolean fitSystemWindows(Rect insets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
mInsets[0] = insets.left;
mInsets[1] = insets.top;
mInsets[2] = insets.right;
return super.fitSystemWindows(insets);
} else {
return super.fitSystemWindows(insets);
}
}
xml 中配置 android:fitsSystemWindows="true"
manifest 中 android:windowSoftInputMode="adjustResize|stateHidden"
fitsSystemWindows = true 放在View 上表示这个View 可以根据情况来收缩