fitsSystemWindows在android studio布局预览中

Wei*_*zhi 6 android android-studio

问题:android:fitsSystemWindows="true"在android studio布局预览中没有考虑布局.为什么会如此,如何在布局预览中正确显示?

我正在使用带有以下标志的主题

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
Run Code Online (Sandbox Code Playgroud)

我有一个布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"/>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

这就是它在预览中的样子 在此输入图像描述

这就是它在设备上的外观 在此输入图像描述

如你所见,"Hello World!" 布局预览中的系统栏重叠(android:fitsSystemWindows此处不起作用),但位于设备上的系统栏下方(android:fitsSystemWindows正在此处工作)