Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating class android.support.design.widget.FloatingActionButton

My app crashed because

Error inflating class android.support.design.widget.FloatingActionButton

This is my code in the XML

<android.support.design.widget.FloatingActionButton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="bottom|right"         android:layout_margin="16dp"         android:src="@drawable/icon_right"         app:backgroundTint="@color/green"         android:onClick="previewphoto"         app:layout_anchorGravity="bottom|right|end" /> 

and here is my gradle

compile 'com.android.support:appcompat-v7:23.4.0' // appcompat library compile 'com.android.support:design:23.4.0' 

my logcat

FATAL EXCEPTION: main Process: com.cyanlabsid.cetakphoto, PID: 15298 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cyanlabsid.cetakphoto/com.cyanlabsid.cetakphoto.PhotoPicker}: android.view.InflateException: Binary XML file line #76: Binary XML file line #76: Error inflating class android.support.design.widget.FloatingActionButton at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) at android.app.ActivityThread.access$900(ActivityThread.java:153) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5441) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628) Caused by: android.view.InflateException: Binary XML file line #76: Binary XML file line #76: Error inflating class android.support.design.widget.FloatingActionButton at android.view.LayoutInflater.inflate(LayoutInflater.java:543) at android.view.LayoutInflater.inflate(LayoutInflater.java:427) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.cyanlabsid.cetakphoto.PhotoPicker.onCreate(PhotoPicker.java:74) at android.app.Activity.performCreate(Activity.java:6303) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)  at android.app.ActivityThread.access$900(ActivityThread.java:153)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5441)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

Can somebody tell my fault?

like image 752
Vanya Rachel Avatar asked Feb 14 '17 08:02

Vanya Rachel


People also ask

Which support library does the FloatingActionButton belong to?

Android Support Library, revision 22.2. 0. FloatingActionButton.

How do I change the color SRC on my floating action button?

To change icon color of Floating Action Button in Kotlin Android we have to set the tint attribute (in layout file) or imageTintList parameter (in Kotlin program) of FAB with the required color.

How do I change the background on my floating action button?

To change background color of Floating Action Button in Kotlin Android, set the backgroundTint attribute (in layout file) or backgroundTintList property (in Kotlin file) of FAB with the required color.


1 Answers

Use

app:backgroundTint 

in stead of

android:backgroundTint 

Hope it will work.

like image 79
Juboraj Sarker Avatar answered Sep 29 '22 11:09

Juboraj Sarker