如何解决错误膨胀类android.support.design.widget.FloatingActionButton

时间:2018-06-17 07:00:21

标签: android runtimeexception

我在某些设备上使用Float ActionButton时遇到问题,(与android版本6.0.1,6.0,5.1.1

我尝试了很多方式,但仍然无法正常工作

我尝试过的方式:

1)我正在使用app:rippleColor =“@ color / white”(而非app:rippleColor =“@ android:color / white”)

2)我正在使用app:backgroundTint =“@ color / fab1”(而不是android:backgroundTint =“@ color / fab2”)

3)我正在使用app:srcCompat =“@ drawable / you_graphics”(而不是android:src =“@ drawable / your_graphics”)

4)我的appcompat和设计支持库版本是相同的:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

这是我的android标签:

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.mvam"
    minSdkVersion 14
    targetSdkVersion 25
    versionCode 5
    versionName "1.7.8"
    testInstrumentationRunner   "android.support.test.runner.AndroidJUnitRunner"
}

这是我的错误:

enter image description here

*java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mvam/com.mvam.activity.ReportActivity}: android.view.InflateException: Binary XML file line #155: Binary XML file line #155: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #155: Binary XML file line #155: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.mvam.activity.ReportActivity.onCreate(ReportActivity.java:77)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)*

,这是我的xml代码

    <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    style="@style/forms_main_layout_stl"
    android:layoutDirection="rtl"
    android:orientation="vertical"
    tools:context="com.mvam.activity.UsersActivity">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray_light"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/main_appbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/coordinate_app_bar_height"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        </android.support.design.widget.AppBarLayout>


        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_members"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"></android.support.v7.widget.RecyclerView>



        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btn_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            app:backgroundTint="@color/orange_colorPrimary"
            app:fabSize="normal"
            app:layout_anchor="@+id/main_appbar"
            app:layout_anchorGravity="bottom|left"
            app:rippleColor="@color/colorAccent"
            app:srcCompat="@mipmap/ic_add_white_" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btn_save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/coordinate_app_bar_save_btn_margin_left"
            app:backgroundTint="@color/orange_colorPrimary"
            app:fabSize="normal"
            app:layout_anchor="@+id/main_appbar"
            app:layout_anchorGravity="bottom|left"
            app:rippleColor="@color/colorAccent"
            app:srcCompat="@mipmap/ic_save_white" />

    </android.support.design.widget.CoordinatorLayout>
</FrameLayout>
你知道吗?我很感激任何帮助

0 个答案:

没有答案