下面棒棒糖材料设计支持 - 崩溃棒棒糖、材料

由网友(拖延是最委婉的拒絕)分享简介:我一直在努力实现材料设计的主题,下面的这些说明。I've been trying to implement the Material Design theme, following these instructions.在我没有使用工具栏(必须我?)在我所有的活动延伸ActionBarActivity。使用 ge...

我一直在努力实现材料设计的主题,下面的这些说明。

I've been trying to implement the Material Design theme, following these instructions.

在我没有使用工具栏(必须我?) 在我所有的活动延伸ActionBarActivity。 使用 getSupportActionBar()所有整个项目。 在我编译和靶向API 21日在摇篮(minimun是API 15)。 在我的&lt;应用&GT; 标记中包含安卓主题=@风格/ AppTheme 运行棒棒糖设备上的应用程序(具有特定的V21类似题材的作品)。 I'm not using ToolBar (must I?) ALL my Activities extends ActionBarActivity. Using getSupportActionBar() all across the project. I'm compiling and targeting to API 21 in gradle (minimun is API 15). My <application> tag contains android:theme="@style/AppTheme" Running the application on Lollipop device (with a specific v21 similar theme works).

我的styles.xml:

My 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)

有没有人遇到这个问题?什么可能会导致这样有什么建议?

Did anyone experience this issue? any suggestions on what might cause this?

编辑: 这是肯定的东西在我的styles.xml主题。如果我强迫应用程序使用默认Theme.AppCompat的主题,它的工作原理。 什么可能导致一个主题失败?我验证了动作条属性不会使用机器人。还要别的吗?

It's definitely something in my styles.xml theme. If I force the app to use the default Theme.AppCompat theme, it works. What might cause a theme to fail? I verified the ActionBar attributes are not using "android:". Anything else?

推荐答案

解决的...

2我的罐子库显然有生成 values​​.xml 包含两种风格的 AppTheme AppBaseTheme 。 我只能证实我们的依赖性模块,罐子图书馆不应该申报申请的主题,特别是不符合的默认的名字。

2 of my jar libs apparently have generated values.xml that contains styles of both AppTheme and AppBaseTheme. I verified only our dependencies modules, as jar libraries shouldn't declare application themes, specially not with the name of the default ones.

在公布答案,我加入到我的的Andr​​oidManifest.xml &lt;应用&GT; 工具:更换=机器人:主题为,并宣布了新的主题,假设它会工作和我的应用程序将覆盖其他任何主题

Before posting the answer, I added to my AndroidManifest.xml <application> tools:replace="android:theme" and declared the new theme, assuming it'll work and my application will override any other theme.

在解决方案最后,愚蠢的,因为它是被重命名自己的 AppTheme AppBaseTheme 以不同的名字,现在它的作品。 时间花费在这样一个小小的更正。我们希望,这将腾出一些时间给别人。

The solution eventually, stupid as it is, was to rename my own AppTheme and AppBaseTheme to different names and now it works. Hours spent on such a trivial fix. Hopefully, this will spare some time for others.

阅读全文

相关推荐

最新文章