浮动操作按钮在灰色背景上显示为白色方块

时间:2020-09-14 08:41:07

标签: android android-studio floating-action-button

我有一个浮动操作按钮,但在Android Studio的预览窗格中,它以灰色背景上的白色块显示。fab image

我尝试过像建议的this answer那样的file>invalidate caches/restart,但是没有用。使用Android Studio 3.6.3

我添加了implementation 'com.google.android.material:material:1.2.1'作为依赖项,并在xml中使用了按钮,如

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/contact_button"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:src="@drawable/ic_call_24px"
        app:backgroundTint="@color/colorPrimaryDark"
        android:contentDescription="@string/contact_details_button"
        android:layout_centerVertical="true"
        />
</RelativeLayout>

运行应用后,它可以正确呈现。有谁知道为什么会这样?

0 个答案:

没有答案
相关问题