问题情况截图如下:
在layout的主布局中加入 android:fitsSystemWindows="true"
如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<!-- 布局内容...... -->
</LinearLayout>
重新运行效果: