Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

floating action button with background tint cause error

I have tried to implement floating action button in my other project with fab and customize it and it works fine. But this time, when I create the fab object in my xml layout, it shows error. Feeling confused, it tried to remove some of it's tag and found out that giving the android:backgroundTint tag is when the error shows up.

Here is the code:

    <android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:fabSize="mini"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_action_fab"
    android:backgroundTint="#2196F3"
    android:layout_margin="12dp"/>

Here is my build:

compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
    applicationId "com.xxxx.xxxx"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 1
    versionName "2.0.4"
}

I have also added the google design gradle.

The error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxx.xxxx/com.xxxx.xxxx.HomeActivity}: android.view.InflateException: Binary XML file line #141: Binary XML file line #141: Error inflating class android.support.design.widget.FloatingActionButton

As soon as i remove the android:backgroundtint tag, the error is gone. Any idea why this is happening?

like image 323
user3576118 Avatar asked Dec 06 '22 14:12

user3576118


1 Answers

Instead of android:backgroundTint="#2196F3", try with app:backgroundTint="#2196F3"

like image 70
John Joe Avatar answered Feb 01 '23 21:02

John Joe