可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
.