无法更改抽屉式导航栏图标的颜色在android系统 [英] Can't change navigation drawer icon color in android

查看:271
本文介绍了无法更改抽屉式导航栏图标的颜色在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我知道这是一个简单的问题,但由于某种原因,它不是为我工作。我已经做了很多事情在其他的答案却徒劳无功建议。我绘制文件夹有白色的图标。我甚至试图把它从styles.xml改变但这并不能工作。我为我的棒棒糖设备上测试它。任何帮助将AP preciated。先谢谢了。

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

 <应用
        机器人:allowBackup =真
        机器人:图标=@绘制/ ic_drawer
        机器人:标签=@字符串/ APP_NAME>
        &所述;元数据
            机器人:名字=com.google.android.gms.version
            机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION
            工具:更换=机器人:值/>        <活动
            机器人:名字=。Activity_Splash
            机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        <活动
                机器人:名字=。Activity_test
                机器人:launchMode =singleInstance
                机器人:主题=@风格/ AppTheme.Base
                机器人:windowSoftInputMode =stateHidden/>

最后,这是我style.xml。类似为V-21

 <样式名称=AppTheme.Base父=Theme.AppCompat.Light.NoActionBar>
        <项目名称=机器人:windowContentTransitions>真< /项目>
        <项目名称=机器人:windowAllowEnterTransitionOverlap>真< /项目>
        <项目名称=机器人:windowAllowReturnTransitionOverlap>真< /项目>
        <项目名称=机器人:actionMenuTextColor>#FFF< /项目>
        <项目名称=colorPrimary> @彩色/ ColorPrimary< /项目>
        <项目名称=colorPrimaryDark> @彩色/ ColorPrimaryDark< /项目>
        <项目名称=drawerArrowStyle> @风格/ MyDrawerArrowToggle< /项目>
        <项目名称=windowActionBar>假LT; /项目>
        <项目名称=colorAccent>#FFF< /项目>
        <项目名称=机器人:windowSharedElementEnterTransition> @android:过渡/移动< /项目>
        <项目名称=机器人:windowSharedElementExitTransition> @android:过渡/移动< /项目>
< /风格>


解决方案

您应该使用 ThemeOverlay.AppCompat.Dark.ActionBar 为您的工具栏风格。它集 colorControlNormal 的android:textColorPrimary ,它是白色的深色主题。而且它不会从主要风格改变其他ATTRS。

 < android.support.v7.widget.Toolbar的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto>
    ...
    机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
    应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
< /android.support.v7.widget.Toolbar>

另外从你的主风格删除 drawerArrowStyle ,这是没有必要的。

OK, I know this is a trivial issue but for some reason it isn't working for me. I have done a lot of things suggested in other answers but in vain. My drawable folder has white color icons. I even tried to change it from styles.xml but that doesn't work either. I am testing it on my Lollipop device. Any help will be appreciated. Thanks in advance.

This is a portion of my manifest file.

    <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" />

And finally this is my style.xml. Similar is for 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>

解决方案

You should use ThemeOverlay.AppCompat.Dark.ActionBar as your toolbar style. It sets colorControlNormal to android:textColorPrimary, which is white for dark themes. And it doesn't change other attrs from main style.

<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>

Also remove drawerArrowStyle from your main style, it's not needed.

这篇关于无法更改抽屉式导航栏图标的颜色在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆