在主动作栏中我有白色主题和紫色主题,如果我选择紫色主题应用程序颜色应更改为紫色,如果我选择白色应用程序颜色应更改为白色,分别按钮和文本颜色也应更改。
我尝试使用我的color.xml
<resources>
<color name="colorPrimary">#36286b</color>
<color name="colorPrimaryDark">#36286b</color>
<color name="colorAccent">#36286b</color>
<color name="button_pressed">#000000</color>
<color name="button_focused">#ff4081</color>
<color name="button_default">#36286b</color>
<color name="button_default1">#f2e9da</color>
<color name="background_white">#f2e9da</color>
<color name="background_purple">#36286b</color>
<color name="textcolor_purple">#36286b</color>
<color name="textcolor_white">#f2e9da</color>
<drawable name="backgroundhome_white">@drawable/kar1</drawable>
<drawable name="backgroundhome_purple">@drawable/kar</drawable>
</resources>
style.xml
<style name="Purple" 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>
<style name="white" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/colorPrimaryLight</item>
</style>
如果我选择白色应用程序应更改为白色,如果我选择紫色应用程序应更改为紫色
答案 0 :(得分:0)
您必须使用Intent
主题必须以这种方式设置:
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Purple);
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
}