Android 使用AppCompact时是否需要特定于版本的样式项?
请检查选项1和选项2,在values-v21样式中定义特定于平台的样式属性(如Android 使用AppCompact时是否需要特定于版本的样式项?,android,styles,android-appcompat,Android,Styles,Android Appcompat,请检查选项1和选项2,在values-v21样式中定义特定于平台的样式属性(如android:colorPrimary)有什么好处 values/styles.xml <resources> <!-- Base application theme. --> <style name="AppTheme" parent="CommonTheme"> </style> <style name="CommonThe
android:colorPrimary
)有什么好处
values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="CommonTheme">
</style>
<style name="CommonTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
选项1:values-v21/styles.xml-通过继承为所有版本使用AppCompact
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="CommonTheme">
<!-- All customization of the theme for this version -->
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="CommonTheme">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
真的
选项2:values-v21/styles.xml-编写平台特定的样式属性以及继承
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="CommonTheme">
<!-- All customization of the theme for this version -->
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="CommonTheme">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
真的
我在不同的地方看到了这两种选择,哪个更好?我们在选项2中有什么优势吗?选项2完全没有必要,因为AppCompat本身会复制颜色,如其:
?属性/颜色初级
?属性/原色暗
?属性/颜色重音
?属性/颜色控制正常
?属性/颜色控制激活
?属性/颜色控制突出显示
?属性/颜色按钮正常
选项2完全没有必要,因为AppCompat本身会复制颜色,如其:
?属性/颜色初级
?属性/原色暗
?属性/颜色重音
?属性/颜色控制正常
?属性/颜色控制激活
?属性/颜色控制突出显示
?属性/颜色按钮正常