自定义 Material 样式无效
Custom Material Style not Working
我有一个最小 sdk 18 的应用程序,它在没有 material 主题样式的情况下也能正常工作,但是当我在 values-v21 中放置一个 material 样式时,应用程序一启动就崩溃了。我已经确认这是崩溃的原因。
我已经看到了必须使用 Base.AppCompat.Holo.Dark 作为父级的 Holo 样式的解决方案。 Material 有类似的东西吗?
我从下面的 values-v21 目录中附加了 styles.xml。请询问您是否需要更多信息。
Android Windows Studio 1.2 在 OnePlus One 上测试 8.1
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
使用 AppCompat 而不是 Material
dependencies {
compile "com.android.support:appcompat-v7:21.0.+"
}
主题:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s actionBarStyle -->
<item name="actionBarStyle">@style/MyActionBarStyle</item>
<!-- Set AppCompat’s color theming attrs -->
<item name=”colorPrimary”>@color/my_awesome_red</item>
<item name=”colorPrimaryDark”>@color/my_awesome_darker_red</item>
<!-- The rest of your attributes -->
</style>
我有一个最小 sdk 18 的应用程序,它在没有 material 主题样式的情况下也能正常工作,但是当我在 values-v21 中放置一个 material 样式时,应用程序一启动就崩溃了。我已经确认这是崩溃的原因。
我已经看到了必须使用 Base.AppCompat.Holo.Dark 作为父级的 Holo 样式的解决方案。 Material 有类似的东西吗?
我从下面的 values-v21 目录中附加了 styles.xml。请询问您是否需要更多信息。
Android Windows Studio 1.2 在 OnePlus One 上测试 8.1
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
使用 AppCompat 而不是 Material
dependencies {
compile "com.android.support:appcompat-v7:21.0.+"
}
主题:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s actionBarStyle -->
<item name="actionBarStyle">@style/MyActionBarStyle</item>
<!-- Set AppCompat’s color theming attrs -->
<item name=”colorPrimary”>@color/my_awesome_red</item>
<item name=”colorPrimaryDark”>@color/my_awesome_darker_red</item>
<!-- The rest of your attributes -->
</style>