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?
Instead of android:backgroundTint="#2196F3"
,
try with app:backgroundTint="#2196F3"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With