2014-03-25 129 views
0

我試圖通過添加一行到主應用程序主題,以改變我的應用程序的基本背景色:更改背景顏色影響兒童

<!-- Application theme. --> 
<style name="AppTheme" parent="AppBaseTheme"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
    <item name="android:background">@android:color/white</item> 
</style> 

但是它級聯到子對象,如動作條和標誌是這樣的:

Weird color cascading

我在做什麼錯?

回答

2

使用android:windowBackground代替background屬性:

<item name="android:windowBackground">@android:color/white</item> 
+0

完美,感謝您的幫助。你能闡明爲什麼我的原代碼級聯那樣嗎?有沒有辦法繼承父母的背景顏色,即使它沒有明確命名? –

+0

不確定,但我認爲你的行爲背景爲所有視圖提供了背景顏色,而windowBackground僅用於背景窗口,請參閱此答案:http://stackoverflow.com/a/16239788/2668136 – Fllo