ความแตกต่างระหว่าง android:Theme.Material.Light.DarkActionBar และ Theme.AppCompat.Light.DarkActionBar

เมื่อฉันใช้รูปแบบต่อไปนี้

<!-- 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>

มันไม่มีข้อผิดพลาด

ทำไม


person Sigma    schedule 23.08.2018    source แหล่งที่มา


คำตอบ (1)


ธีม android:Theme.Material.Light.DarkActionBar ขึ้นอยู่กับ OS หรือไม่

แม้ว่าเวอร์ชัน appcompat จะถูกเพิ่มลงใน apk ของคุณอย่างชัดเจน นอกจากนี้ หากคุณใช้ AppcompatActivity ควรใช้ ธีม Appcompat จะดีกว่า เพราะจะหลีกเลี่ยงความขัดแย้ง

person R7G    schedule 23.08.2018