android.view.InflateException:二进制XML文件行#31:膨胀类android.support.design.widget.FloatingActionButton时出错
每当我尝试在我的应用程序中添加一个FloatingActionButton时,我都会收到一个InflateException。 以下是我的XML:android.view.InflateException:二进制XML文件行#31:膨胀类android.support.design.widget.FloatingActionButton时出错,android,Android,每当我尝试在我的应用程序中添加一个FloatingActionButton时,我都会收到一个InflateException。 以下是我的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/t
<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>
在gradle中添加设计支持库
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
在gradle中添加设计支持库
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
这样试试
<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>
试试这种方法
<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>