微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在android中更改导航抽屉图标颜色

好的,我知道这是一个微不足道的问题,但由于某种原因它不适合我.我在其他答案中做了很多建议但是徒劳无功.我的drawable文件夹有白色图标.我甚至试图从styles.xml更改它,但这也不起作用.我在我的Lollipop设备上测试它.任何帮助将不胜感激.提前致谢.

这是我的清单文件的一部分.

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_drawer"
        android:label="@string/app_name" >
        <Meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"
            tools:replace="android:value" />

        <activity
            android:name=".Activity_Splash"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
                android:name=".Activity_test"
                android:launchMode="singleInstance"
                android:theme="@style/AppTheme.Base"
                android:windowSoftInputMode="stateHidden" />

最后这是我的style.xml.类似于v-21.

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">true</item>
        <item name="android:windowAllowReturnTransitionOverlap">true</item>
        <item name="android:actionMenuTextColor">#fff</item>
        <item name="colorPrimary">@color/ColorPrimary</item>
        <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
        <item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
        <item name="windowActionBar">false</item>
        <item name="colorAccent">#fff</item>
        <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
        <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

解决方法

您应该使用ThemeOverlay.AppCompat.Dark.ActionBar作为工具栏样式.它将colorControlnormal设置为android:textColorPrimary,黑色主题为白色.它并没有改变其他主流风格.
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" >
    ... 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
</android.support.v7.widget.Toolbar>

同时从主要样式中删除drawerArrowStyle,不需要它.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐