我一直在尝试实施Material Design主题,关注these instructions。下面的棒棒糖材料设计支持 - 崩溃
- 我不使用
ToolBar
(必须我?) - 我所有的活动延伸ActionBarActivity。
- 在整个项目中使用
getSupportActionBar()
。 - 我正在编译和定位到gradle中的API 21(最小值是API 15)。
- 我的
<application>
标签包含android:theme="@style/AppTheme"
- 运行棒棒糖设备上的应用程序(与特定v21类似的主题作品)。
我styles.xml:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="displayOptions">useLogo|showHome</item>
<item name="logo">@drawable/home_page_logo</item>
<item name="background">@color/actionbar_background_color</item>
<item name="textColor">@color/white</item>
<item name="titleTextStyle">@style/MyActionBarTextStyle</item>
</style>
不管我试过了,应用程序崩溃的第二启动我的主要活动上onCreate()
与此崩溃日志:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
这儿还有没有人遇到这个问题?有什么建议可能会导致这种情况?
编辑: 这绝对是我的styles.xml主题中的东西。如果我强制应用程序使用默认的Theme.AppCompat主题,它的工作原理。 什么可能导致主题失败?我验证了ActionBar属性没有使用“android:”。还要别的吗?
@PearsonArtPhoto耶...再次验证。所有模块都针对v21。 – 2015-02-17 20:51:45
@PearsonArtPhoto干净,重建,gradle同步......基本上所有的 – 2015-02-17 20:55:42