0
請檢查選項1和選項2,在values-v21樣式中定義平臺特定樣式屬性(如android:colorPrimary
)有什麼優勢。使用AppCompact時需要哪些特定於版本的樣式項?
值/ 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:值-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>
選項2:值-V21/styles.xml - 寫作平臺特定的風格一起繼承屬性。
<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中有什麼優勢嗎?