Android 更改导航抽屉菜单项中的开关颜色

Android 更改导航抽屉菜单项中的开关颜色,android,android-layout,android-switch,Android,Android Layout,Android Switch,更改导航抽屉开关项目的颜色时遇到问题。我希望每个人都有一个自定义的颜色与它的行动 我用如下菜单定义了导航抽屉: <item android:title="@string/nav_drawer_services_title"> <menu> <group android:checkableBehavior="none"> <item android:id="@+id/R

更改导航抽屉开关项目的颜色时遇到问题。我希望每个人都有一个自定义的颜色与它的行动

我用如下菜单定义了导航抽屉:

<item
    android:title="@string/nav_drawer_services_title">
    <menu>
        <group android:checkableBehavior="none">
            <item
                android:id="@+id/Red_selector"
                android:title="@string/nav_drawer_red_title"
                app:actionLayout="@layout/switch_layout"/>
            <item
                android:id="@+id/Blue_selector"
                android:title="@string/nav_drawer_blue_title"
                app:actionLayout="@layout/switch_layout"/>
        </group>
    </menu>
</item>

只需使用android:theme=“@style/MyCustomSwitchTheme”


相反,
style=“@style/MyCustomSwitchTheme”

我看不到任何颜色变化声明。请发布你的主题代码。哇。。。我很笨。(或者至少今天盯着屏幕看的时间太长了。)我讨厌在发帖前忽略一些小的打字错误。谢谢,你说得对!
<Switch
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:onClick="toggleService"
android:checkable="true"
android:checked="true"
style="@style/MyCustomSwitchTheme"
/>
<style name="MyCustomSwitchTheme">
    <!-- active thumb & track color (30% transparency) -->
    <item name="colorControlActivated">#46bdbf</item>

    <!-- inactive thumb color -->
    <item name="colorSwitchThumbNormal">@color/light_gray_color</item>

    <!-- inactive track color (30% transparency) -->
    <item name="android:colorForeground">#42221f1f</item>
</style>