更新时间:2022-12-29 08:18:50
您应该使用 ThemeOverlay.AppCompat.Dark.ActionBar
为您的工具栏风格。它集 colorControlNormal
到的android:textColorPrimary
,它是白色的深色主题。而且它不会从主要风格改变其他ATTRS。
< android.support.v7.widget.Toolbar的xmlns:程序=http://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.