Error inflating class android.support.design.widget.CoordinatorLayoute

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I am trying to run my application and I keep getting the error listed in the title. I've read around and people have said to try changing theme to an AppCombat theme but that does not seem to be working. Here are my errors I am getting:

XML FILE: activity_game.xml

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayoute     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"     android:fitsSystemWindows="true"     tools:context=".GameActivity">      <android.support.design.widget.AppBarLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:theme="@style/Theme.AppCompat.Light.DarkActionBar">          <android.support.v7.widget.Toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionBarSize"             android:background="?attr/colorPrimary"             app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />      </android.support.design.widget.AppBarLayout>      <include layout="@layout/content_game" />  </android.support.design.widget.CoordinatorLayoute> 

Any help would be appreciated!

回答1:

Replace

    <?xml version="1.0" encoding="utf-8"?>     <android.support.design.widget.AppBarLayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:theme="@style/Theme.AppCompat.Light.DarkActionBar">      <android.support.v7.widget.Toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionBarSize"         android:background="?attr/colorPrimary"         app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />     </android.support.design.widget.AppBarLayout>     <include layout="@layout/content_game" /> 

With

<android.support.design.widget.CoordinatorLayout  xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent">  <android.support.design.widget.AppBarLayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:theme="@style/Theme.AppCompat.Light.DarkActionBar">      <android.support.v7.widget.Toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionBarSize"         android:background="?attr/colorPrimary"         app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />  </android.support.design.widget.AppBarLayout>  <include layout="@layout/content_game" /> </android.support.design.widget.CoordinatorLayout> 

Also add compile 'com.android.support:design:22.2.1' in build.gradle



回答2:

You have a spelling error in your layout file. Change CoordinatorLayoute to CoordinatorLayout.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!