0

Whenever I try to add a FloatingActionButton to my app, I get an InflateException. Here is my XML:

<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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="wtw.sunonetaji.landing.MainScreenListActivity">
    <LinearLayout
        android:id="@+id/activity_main_screen_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="wtw.sunonetaji.landing.MainScreenListActivity">
        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" />
    </LinearLayout>
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:backgroundTint="@color/bgcoloor"
        android:clickable="true"
        android:padding="10dp"
        android:src="@drawable/pencileditbutton"
        app:borderWidth="1dp" />
</FrameLayout>

Here is my exception:

Caused by: android.view.InflateException: Binary XML file line #31: Error inflating class android.support.design.widget.FloatingActionButton

2 Answers 2

2

try this way

<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="wtw.sunonetaji.landing.MainScreenListActivity">


<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/activity_main_screen_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="wtw.sunonetaji.landing.MainScreenListActivity">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" />
    </LinearLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    app:backgroundTint="@color/bgcoloor"
    android:clickable="true"
    android:padding="10dp"
    android:src="@drawable/pencileditbutton"
    app:borderWidth="1dp" />
</android.support.design.widget.CoordinatorLayout></RelativeLayout>
Sign up to request clarification or add additional context in comments.

Comments

0

add Design Support Library in gradle

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.