Error inflating class android.support.design.widget.FloatingActionButton - android -
i want run activity got error :
android.view.inflateexception: binary xml file line #21: error inflating class android.support.design.widget.floatingactionbutton @ android.app.activitythread.performlaunchactivity(activitythread.java:2693) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2758) @ android.app.activitythread.access$900(activitythread.java:177) @ android.app.activitythread$h.handlemessage(activitythread.java:1448) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:145) @ android.app.activitythread.main(activitythread.java:5942) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1389) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1184) caused by: android.view.inflateexception: binary xml file line #21: error inflating class android.support.design.widget.floatingactionbutton
my xml code :
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <listview android:id="@+id/listview_diary" android:layout_width="match_parent" android:layout_height="match_parent" android:cliptopadding="false" android:divider="@null" android:dividerheight="16dp" android:fadingedge="none" android:fitssystemwindows="true" android:padding="12dp" android:scrollbars="none" android:background="@android:color/white"/> <android.support.design.widget.floatingactionbutton xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fab_add_diary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_margin="16dp" android:clickable="true" android:padding="8dp" android:src="@mipmap/ic_add" app:backgroundtint="@color/colorprimary" app:borderwidth="0dp"/> </relativelayout>
my class extended appcompatactivity
class.
my style :
<style name="apptheme" parent="theme.appcompat.light.darkactionbar">
my gradle :
apply plugin: 'com.android.application' android { compilesdkversion 24 buildtoolsversion "25.0.0" defaultconfig { applicationid "***.***.***" minsdkversion 16 targetsdkversion 24 versioncode 1 versionname "1.0" jackoptions { enabled true } // enabling multidex support. multidexenabled true } buildtypes { release { debuggable false minifyenabled false shrinkresources false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } compileoptions { sourcecompatibility javaversion.version_1_8 targetcompatibility javaversion.version_1_8 } dexoptions { javamaxheapsize "2g" incremental true predexlibraries = false } } repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url 'https://raw.github.com/felipecsl/m2repository/master' } // maven { url "https://jitpack.io" } mavencentral() } dependencies { compile filetree(include: ['*.jar'], dir: 'libs') compile('com.github.florent37:materialviewpager:1.2.0@aar') { transitive = true } compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:recyclerview-v7:24.0.0' compile 'com.android.support:design:24.0.0' compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:cardview-v7:24.0.0' compile 'com.android.support:support-v4:24.0.0' ...
try this
1 . update design support library , appcompat library using sdk manager installs latest versions.
2. use appcompat theme.
3. extend activity appcompatactivity instead of activity.
4. try keep version of both libraries same
compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:design:24.2.0'
5. after these clean project , run .
Comments
Post a Comment