当我使用以下样式
<!-- 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:Theme.Material.Light.DarkActionBar。 OS依赖
虽然appcompat版本已明确添加到您的apk中。此外,如果您使用的是AppcompatActivity,最好使用Appcompat主题,这样可以避免冲突。