1

My FloatingActionButton is greyed out. I've tried using the Coordinator layout but it isn't working. Below are the screenshot of the problem and a code snapshot.

Screenshot

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    style="@style/AppTheme">
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/alarms_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:scrollbars="vertical"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="83dp"
        android:layout_height="61dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        android:src="@drawable/ic_add_alarm_black_24dp"
        app:backgroundTint="#FFFFFF"
        app:fabSize="normal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"></com.google.android.material.floatingactionbutton.FloatingActionButton>
</androidx.constraintlayout.widget.ConstraintLayout>
normanius
  • 8,629
  • 7
  • 53
  • 83
Raunak Pandey
  • 371
  • 2
  • 16
  • 1
    Follow this : https://stackoverflow.com/questions/30969455/android-changing-floating-action-button-color – Ali Jan 06 '20 at 13:21

2 Answers2

1

First if you use AndroidX be sure to include the following dependency to your app gradle.

implementation 'com.google.android.material:material:1.0.0'

Next replace your FAB in the XML with the code below. The FAB should appear in the bottom-right corner of the screen.

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginBottom="32dp"
        android:src="@drawable/ic_add_alarm_black_24dp"
        android:background="@color/colorAccent"
        app:backgroundTint="@color/colorAccent"
        app:fabSize="normal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />
davidm
  • 1,570
  • 11
  • 24
0

try this n the xml:

app:backgroundTint="@color/red"
Hernâni Pereira
  • 312
  • 4
  • 19