Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在选择上更改android应用程序的主题_Android - Fatal编程技术网

在选择上更改android应用程序的主题

在选择上更改android应用程序的主题,android,Android,在主操作栏中我有白色主题和紫色主题,如果我选择紫色主题,应用程序颜色应更改为紫色,如果我选择白色应用程序颜色应更改为白色,分别按钮和文本颜色也应更改 我尝试了我的color.xml <resources> <color name="colorPrimary">#36286b</color> <color name="colorPrimaryDark">#36286b</color> <color name=

在主操作栏中我有白色主题和紫色主题,如果我选择紫色主题,应用程序颜色应更改为紫色,如果我选择白色应用程序颜色应更改为白色,分别按钮和文本颜色也应更改

我尝试了我的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>

#36286b
#36286b
#36286b
#000000
#ff4081
#36286b
#f2e9da
#f2e9da
#36286b
#36286b
#f2e9da
@可抽出式/kar1
@可抽出式/卡式
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>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@彩色/彩色原色光

如果我选择白色应用程序应更改为白色,如果我选择紫色应用程序应更改为紫色

您必须以
意图重新启动活动

主题必须按以下方式设置:

public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Purple);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.your_activity);
}

您想更改哪些按钮?您的两个主题完全相同…请尝试此链接,但我仍然没有得到,任何人请给出示例