在 Android Studio 中使用 FAB 时来自 style.xml 的错误

Errors from style.xml while using the FAB in Android Studio

我有 "Rendering Errors" 来自 style.xml 文件。这是 FAB xml 块:

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/floatingActionButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16dp"
    android:layout_marginEnd="16dp"
    android:src="@drawable/baseline_add_white_36dp"
    android:theme="@style/MyFloatingButton"
    app:backgroundTint="#008080"
    app:fabSize="normal"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:rippleColor="#00b3b3" />

style.xml块:

<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <style name="MyFloatingButton" parent="Theme.AppCompat">
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>
</style>

如果我在这里犯了一个愚蠢的错误,那是因为我是新手,这是我的第一个应用程序。我试过一个干净的构建,没有帮助。

在您的 style.xml 文件中,将 MyFloatingButton 样式放在 AppTheme 样式之外,如下所示:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
     ...
</style>

<style name="MyFloatingButton" parent="Theme.AppCompat">
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>