android:Theme.Material.Light.DarkActionBar和Theme.AppCompat.Light.DarkActionBar之间的区别

问题描述 投票:0回答:1

当我使用以下样式

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

我收到错误:

java.lang.RuntimeException:无法启动活动ComponentInfo {com.xx.xx / com.xx.xx.setup.SetupASelectLanguageActivity}:java.lang.IllegalStateException

当我将其更改为:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

它没有错误。

为什么?

android android-appcompat android-theme
1个回答
0
投票

主题android:Theme.Material.Light.DarkActionBar。 OS依赖

虽然appcompat版本已明确添加到您的apk中。此外,如果您使用的是AppcompatActivity,最好使用Appcompat主题,这样可以避免冲突。

© www.soinside.com 2019 - 2024. All rights reserved.