xml - Floating Action Button could not be instantiated / Error inflating -
i've been tearing hair out; working fine ( well.. almost, wasn't floating right) , stopped shortly after added android:backgroundtint="@color/fab"
minimum sdk 19.
to try , fix have:
- updated android studio / sdk
- invalidate caches / restart
- rebuilt project
- confirmed
targetsdkversion 23
- confirmed
compile 'com.android.support:design:23.1.1'
- confirmed
classpath 'com.android.tools.build:gradle:1.5.0'
- confirmed
<style name="apptheme" parent="theme.appcompat.light.darkactionbar">
it's coming 5am sorry if glaringly obvious don't know else try. xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/com.whereintheworld.com" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.coordinatorlayout android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <listview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tracking_task_list" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </linearlayout> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:clickable="true" android:src="@drawable/fab_ic_add" android:backgroundtint="@color/fab" app:layout_anchor="@id/tracking_task_list" app:layout_anchorgravity="bottom|right|end" /> </android.support.design.widget.coordinatorlayout> </relativelayout>
com.android.support:appcompat-v7:21+
added support tinting widgets on devices running pre android 5.1 (api level 21)
. make use of make sure extend or set appcompat theme , use app:backgroundtint
instead of android:backgroundtint
.
example:
<android.support.design.widget.floatingactionbutton xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:src="@drawable/icon" app:backgroundtint="@color/accent" app:borderwidth="0dp" />
Comments
Post a Comment