Is it possible to change overflow icon in code?
I read this solution: Changing overflow icon in the action bar
But I need to make it in code, to select white or grey style during runtime.
Is it possible?
You can only change this in a theme.
One potential solution would be to call setTheme as the very first thing in onCreate with different themes depending on whether you needed white or gray.
Related
I have created 2 fragments and made them overlap using bottom sheet. First one fragment opens, then the second framgment opens, but when the 2nd fragment is closed,the colour of the status bar icons change to white if the status bar background is white and same for dark.
How do I fix this? Or how do I change the colour of status bar icons?
I have read the docs and read about WindowInsetsController but this will do it for android R only. My issue persists for all versions.
Please help.
You can't change the icons with a specific color but with that in your styles.xml file you can make it light or dark. Keep in mind that it only works API 23 and above.
<item name="android:windowLightStatusBar">true</item>
More references or ways of individual solutions you can find at this post.
The primary color of my application is white and hence my navigation bar color is also white. My problem is that navigation bar buttons are also white in color. How do I make sure that buttons are visible in white background. The app theme I have used is Theme.AppCompat.Light.DarkActionBar.
I have tried using different theme but none seem to be working so far.
Can anyone tell me how I could resolve this issue?
For Android Oreo and above you can try this:
View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_NAVIGATION.
You can also refer here for more details: https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
Also there is another approach:
you can achieve it by placing this in your theme:
<item name="android:windowLightNavigationBar">true</item>
I have been having an issue where my overflow settings button appears black and makes the text difficult to read. I instead want the settings button to appear like this as that is how it shows up in my menu.xml
I have tried searching for a solution but most of them are how to change the color of the three dots and not of the actual options. Any help solving the issue would be appreciated.
Did you try using a light theme? like Theme.AppCompat.Light.NoActionBar
I have an action bar that has a specific theme to it(some sort of color) that I want to apply to all activities/fragments that looks something like the attached picture.
Then once I click the dropdown, I'd like the dropdown background to be a different color. How would I go about styling that background.
Right now this is theme I have
<item name="toolbarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar.WhiteDropDown</item>
Once I click the dropdown menu, the background of the dropdown appears to be black. What should I do to change that?
I've tried creating a subclass of #style/ThemeOverlay.AppCompat.Light and change the entire toolbarTheme to that style. But at the same time, the actionBar texts now all appear in black since its style is Light, and to contrast that, the texts will be black in default. Therefore, I'm wondering if there's any other attribute I can modify just to change the background of the dropdown menu.
I've tried, actionMenuTextColor, actionBarPopupTheme, spinnerDownItemStyle, actionBarItemBackground, actionDropDownStyle, and everything I can think of. Someone please help out!
Thanks!
I've used the action bar style generator to generate a custom action bar theme for an app, and it works well after a few tweaks. My custom theme is based on Holo (the dark version) and changes the highlight colours. My action bar overflow menu correctly shows my custom state_pressed colour on the overflow items when I press them. I've set android:colorPressedHighlight to the colour I want, and put an appropriate drawable for android:selectableItemBackground.
The problem is on one of my test devices, which has a hard menu button. (It's a Samsung Galaxy S III.) When I show the overflow menu with the hard menu button, pressing an item from this menu gives it the default blue highlight. Either it uses another attr instead of android:selectableItemBackground, or it's taking it from another style. I'd like to know what attr it's using, or what style it's taking it from, so that I can set this colour.
P.S. Before anyone suggests it, I know that you can use android:panelBackground to set the background of the bottom menu. But I don't want to change the overall menu background, only the item background.