Ad

Floating Action Button Appears As A Gray Box

I'm trying to have a FAB at the bottom-right corner of my screen to float on top of the recyclerview. However, the FAB is just a gray box with the widget's path.

Here is the problem:

enter image description here This is my XML implementation:

<RelativeLayout 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"
    tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/userpass_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/generate_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_margin="16dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:clickable="true"
        android:focusable="true" />

</RelativeLayout>

dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.android.support:design:28.0.1'
    implementation 'com.google.android.material:material:1.1.0-alpha05'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Ad

Answer

Try file>invalidate caches/restart. That's the issue I had with some of my widgets that were greyed out.

Ad
source: stackoverflow.com
Ad