I have searched how to change the icon color but i have no success on it.
this is my style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarDivider">#android:color/transparent</item>
<item name="android:actionBarTabBarStyle">#style/AppTheme.TabBar</item>
<item name="actionBarTabBarStyle">#style/AppTheme.TabBar</item>
<item name="colorPrimary">#color/main_organization_base_color_1</item>
<item name="colorPrimaryDark">#color/main_organization_color</item>
<item name="colorAccent">#color/main_organization_base_color_2</item>
<item name="android:textColorPrimary">#color/text_color_primary</item>
<item name="android:textColorSecondary">#color/palette_flat_asphalt_3</item>
<item name="android:colorBackground">#color/default_bg_color</item>
<item name="android:windowBackground">#color/default_bg_color</item>
<item name="android:textColorPrimaryInverse">#color/text_color_primary_inverse</item>
<item name="colorControlNormal">#color/color_control_normal</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
<item name="background">#color/action_background_color</item>
</style>
<style name="MyTitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
But icon keeps appearing in black color when none of those colors are black or dark. (just colorPrimaryDark is dark blue)
Related
I am trying to draw a white navigation bar with black button on splash (Theme.Paper.Launcher) and after change a background color to #color/primary_dark (Theme.Paper):
style-v27:
<resources>
<!-- Basic paper theme -->
<style name="Theme.Paper" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary</item>
<item name="colorAccent">#color/accent</item>
<item name="windowNoTitle">true</item>
<item name="actionModeStyle">#style/Widget.Paper.ActionMode</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeCloseDrawable">#drawable/ic_close_white_24dp</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:navigationBarColor">#color/primary_dark</item>
<item name="android:windowLightNavigationBar">false</item>
</style>
<!-- Splash theme. -->
<style name="Theme.Paper.Launcher" parent="Theme.Paper">
<item name="colorPrimary">#android:color/white</item>
<item name="colorPrimaryDark">#android:color/white</item>
<item name="android:windowBackground">#drawable/bg_splash</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:navigationBarColor">#android:color/white</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
</resources>
But my navigation bar is still black with white buttons. What am I doing wrongly?
P.S. There is Android Oreo on my phone...
Text color of DatePickerDialog gets white in oreo(Google pixel) devices as per below image which is looks perfect in pre-oreo devices.
Also drawer menu fonts become white as per below image which is again looks perfect in pre-oreo devices.
Disable Switch color become white as per below image
In my gradle file :
compileSdkVersion 26
buildToolsVersion "26.0.2"
targetSdkVersion 26
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
Style.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/newcolorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="android:actionButtonStyle">#style/ActionButtonStyle</item>
<item name="colorControlNormal">#color/white</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<!-- Active thumb color & Active track color(30% transparency) -->
<item name="colorControlActivated">#color/colorAccent</item>
<!-- Inactive thumb color -->
<item name="colorSwitchThumbNormal">#color/white</item>
<!-- Inactive track color(30% transparency) -->
<item name="android:colorForeground">#color/white</item>
</style>
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowNoTitle">true</item>
<item name="android:background">#color/transparent</item> //Your custom background color
</style>
<!--this will reduce space between actionBar Icons-->
<style name="ActionButtonStyle" parent="Widget.AppCompat.ActionButton">
<item name="android:paddingLeft">5dip</item>
<item name="android:paddingRight">5dip</item>
</style>
<style name="StarRatingBar" parent="#android:style/Widget.RatingBar">
<item name="android:progressDrawable">#drawable/bg_rating_bar</item>
<item name="android:numStars">5</item>
</style>
<style name="Base.Widget.Design.TabLayout" parent="android:Widget">
<item name="tabBackground">#drawable/tab_bar_selector</item>
<!--<item name="tabIndicatorColor">#color/white</item>
<item name="tabIndicatorHeight">4dp</item>-->
</style>
<style name="Widget.CardContent" parent="android:Widget">
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:paddingTop">24dp</item>
<item name="android:paddingBottom">24dp</item>
<item name="android:orientation">vertical</item>
</style>
<style name="MenuLabelsStyle">
<item name="android:background">#drawable/fab_label_background</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:textSize">14sp</item>
<item name="android:maxLines">2</item>
<item name="android:ellipsize">end</item>
</style>
<style name="MenuButtonsStyle">
<item name="fab_size">normal</item>
<item name="fab_showAnimation">#anim/jump_from_down</item>
<item name="fab_hideAnimation">#anim/jump_to_down</item>
<item name="fab_shadowColor">#444</item>
<item name="fab_colorNormal">?attr/colorPrimaryDark</item>
<item name="fab_colorPressed">?attr/colorPrimary</item>
<item name="fab_colorRipple">?attr/rippleColor</item>
</style>
<style name="MenuButtonsSmall">
<item name="fab_size">mini</item>
<item name="fab_colorNormal">#1565C0</item>
<item name="fab_colorPressed">#2272CD</item>
<item name="fab_colorRipple">#62B2FF</item>
</style>
<style name="MenuButtonsSmall.Green">
<item name="fab_colorNormal">#43A047</item>
<item name="fab_colorPressed">#2E7D32</item>
<item name="fab_colorRipple">#1B5E20</item>
</style>
<style name="MenuButtonsSmall.AppColor">
<item name="fab_colorNormal">#color/colorPrimaryTrans</item>
<item name="fab_colorPressed">#color/colorPrimaryDarkTrans</item>
<item name="fab_colorRipple">#color/colorAccentTrans</item>
<item name="fab_size">normal</item>
</style>
<style name="FavTextInput1" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#color/gray_9ea</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#color/colorAccent</item>
<item name="colorControlNormal">#color/gray_9ea</item>
<item name="colorControlActivated">#color/colorAccent</item>
</style>
<style name="FavTextInput2" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#color/gray_9ea</item>
<item name="android:textSize">14sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#color/colorAccent</item>
<item name="colorControlNormal">#color/gray_9ea</item>
<item name="colorControlActivated">#color/colorAccent</item>
</style>
<style name="TextLabel" parent="Widget.Design.TextInputLayout">
<item name="android:textColorHint">#color/white_lite</item>
</style>
<style name="TextError" parent="Widget.Design.TextInputLayout">
<item name="android:textColor">#color/white_lite</item>
</style>
<style name="Color1SwitchStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorControlActivated">#color/colorAccent</item>
<item name="colorSwitchThumbNormal">#color/light_gray</item>
<item name="android:colorForeground">#color/dark_gray</item>
</style>
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorPrimaryInverse">#color/black</item>
</style>
<style name="MyDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:textColorPrimary">#color/black</item>
</style> </resources>
Let me know if any more information want.
Thanks in advance.
Check your res/Values/Styles.xml
https://developer.android.com/training/material/theme.html
What you should take closer took at is:
Style parent
Play around with: "textColorSecondary","textColor"
I want to change the text color and the navigation icon color in the toolbar
Change the text color of the action item "13311"
And also of the drawer icon.
The styles
//activity theme
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="colorPrimaryDark">#color/ColorPrimaryDark</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="switchStyle">#style/Switch</item>
</style>
//theme for switch widget
<style name="Switch" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="android:thumb">#drawable/switch_selector</item>
<item name="showText">false</item>
</style>
//toolbar theme
<style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:gravity">center_vertical</item>
<!--<item name="popupTheme">#style/PopupMenuStyle</item>-->
<item name="actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
//overflow menu theme
<style name="PopupMenuStyle" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/black</item>
<item name="android:gravity">left|center</item>
<item name="android:background">#color/white</item>
</style>
//action button theme
<style name="MyActionButtonStyle" parent="AppBaseTheme">
<item name="android:minWidth">0dip</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
<style name="MyDarkToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<!-- text color for action menu icons -->
<item name="android:textColorSecondary">#fff</item>
<!-- overflow menu icon color -->
<item name="actionMenuTextColor">#fff</item>
</style>
Edit
To change the navigation drawer color use
<style name="DrawerStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/drawer_color</item>
</style>
change the parent theme to darkactionbar
when the action bar is dark you will get your icon and text white , when it is light you will get them black .
that's all
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
To change arrow color I used colorControlNormal
from AppTheme and AppTheme.ActionBarTheme
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="windowActionBar">false</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">#android:color/white</item>
<item name="actionBarTheme">#style/AppTheme.ActionBarTheme</item>
<item name="android:itemTextAppearance">#style/ToolbarTextAppearance</item>
<!-- Material Theme -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/accent_color</item>
<item name="android:statusBarColor" tools:targetApi="21">#color/statusBarColor</item>
<item name="android:navigationBarColor" tools:targetApi="21">#color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="AppTheme.ActionBarTheme" parent="#style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">#android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/drawerArrowColor</item>
</style>
<style name="ToolbarTextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>
I have a custom theme for my appcompat action bar, however the action icons (back icon and overflow menu buttons) are black but I am using the android:icon="#android:drawable/stat_sys_upload" and the background for this is staying white and I want this to be black.
Below is my theme code;
<style name="Theme.Alcontrol" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_alcontrol</item>
<item name="popupMenuStyle">#style/PopupMenu.Alcontrol</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Alcontrol</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Alcontrol</item>
<item name="actionDropDownStyle">#style/DropDownNav.Alcontrol</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Alcontrol</item>
<item name="actionModeBackground">#drawable/cab_background_top_alcontrol</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_alcontrol</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Alcontrol</item>
</style>
<style name="ActionBar.Solid.Alcontrol" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_alcontrol</item>
<item name="backgroundStacked">#color/white</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_alcontrol</item>
<item name="progressBarStyle">#style/ProgressBar.Alcontrol</item>
</style>
<style name="ActionBar.Transparent.Alcontrol" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_alcontrol</item>
<item name="progressBarStyle">#style/ProgressBar.Alcontrol</item>
</style>
<style name="PopupMenu.Alcontrol" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_alcontrol</item>
</style>
<style name="DropDownListView.Alcontrol" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_alcontrol</item>
</style>
<style name="ActionBarTabStyle.Alcontrol" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_alcontrol</item>
</style>
<style name="DropDownNav.Alcontrol" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_alcontrol</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_alcontrol</item>
<item name="android:dropDownSelector">#drawable/selectable_background_alcontrol</item>
</style>
<style name="ProgressBar.Alcontrol" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_alcontrol</item>
</style>
<style name="ActionButton.CloseMode.Alcontrol" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_alcontrol</item>
</style>
In my main theme, I include this:
<item name="android:popupMenuStyle">#style/ListPopupWindow</item>
in styles.xml:
<style name="ListPopupWindow" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:textColor">#color/bright_foreground_holo_dark</item>
</style>
where bright_foreground_holo_dark is a light gray (#fff3f3f3). Yet the text appears as black. The background is a dark gray, as it should be in the dark holo theme.
These definitions are in the android styles.xml source.
<style name="Widget.Holo.ListPopupWindow" parent="Widget.ListPopupWindow">
<item name="android:dropDownSelector">#android:drawable/list_selector_holo_dark</item>
<item name="android:popupBackground">#android:drawable/menu_dropdown_panel_holo_dark</item>
<item name="android:dropDownVerticalOffset">0dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>
<style name="Widget.ListPopupWindow">
<item name="android:dropDownSelector">#android:drawable/list_selector_background</item>
<item name="android:popupBackground">#android:drawable/spinner_dropdown_background</item>
<item name="android:dropDownVerticalOffset">-10dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>
<style name="Widget">
<item name="android:textAppearance">?textAppearance</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">?textColorPrimary</item>
<item name="android:textColorHighlight">?textColorHighlight</item>
<item name="android:textColorHint">?textColorHint</item>
<item name="android:textColorLink">?textColorLink</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
</style>
Just in case someone is looking for help,
To change the font color of overflow menu item, your main theme should include
<item name="android:textAppearanceLargePopupMenu">#style/PopupMenuTextAppearance</item>
and in style.xml
<style name="PopupMenuTextAppearance" parent="android:TextAppearance.Large">
<item name="android:textColor">#color/bright_foreground_holo_dark</item>
</style>
choose any parent TextAppearance.Medium /TextAppearance.Small depending upon needs.