主題是風格也因此,如果你想你的整個應用程序從例如驅動Holo.light你可以簡單地定義一個樣式像下面,改變你想要的顏色和樣式預定義的元素,然後設置在體現你的應用主題:
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="progressBarStyle">@android:style/Widget.ProgressBar.Inverse</item>
<item name="progressBarStyleSmall">@android:style/Widget.ProgressBar.Small.Inverse</item>
<item name="progressBarStyleLarge">@android:style/Widget.ProgressBar.Large.Inverse</item>
</style>
但如果你想設置背景顏色爲您的活動,並改變它在運行時或通過點擊菜單項,我認爲更好的方法是定義兩個樣式的根元素(在活動佈局最外層的元素),並定義背景像這些元素:
<style name="LinearLayoutLight">
<item name="android:background">@color/#somecolor</item>
</style>
<style name="LinearLayoutDark">
<item name="android:background">@color/#somecolor</item>
</style>
@SamanMoradiZiarani:親愛的薩滿TY接受,你的第一個問題ü在style.xml定義風格,那麼在你的活動佈局使用: style元素中的style =「@ style/yourstyle」。用於在運行時在stackOverFlow中更改主題,您可以找到很好的答案。它的回答太寬泛,無法回答。 –
@SamanMoradiZiarani:用背景物品創建另一種風格,然後將這種風格分配給這些元素。 –
@SamanMoradiZiarani:你爲什麼重複接受一個unccepting的答案!!? –