Actionbar Overflow Button looks transparent - android

I dont know why but because of some reasons my overflow button in my actionbar is transparent.Are there any reasons for that and how can I fix it ? Whats the default style for it ? I dont want to download material icons from Google because I think they should be already in it.
My AppTheme style :
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:windowFullscreen">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">#color/colorPrimary</item>
<item name="colorAccent">#color/colorPrimary</item>

Related

How to change the theme of contextual action bar

I have use toolbar in my app with style
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/holo_blue</
<item name="actionModeStyle">#style/Search.ActionMode</item>
<item name="windowActionModeOverlay">true</item>
</style>
Then I used a contextual action bar and able to change the background color.
<style name="Search.ActionMode" parent="#style/Widget.AppCompat.ActionMode">
<item name="background">#color/actionModeColor</item>
</style>
But I am unable to change the background color of popup menu.
Here is the image
And I wanted the background color of popup menu to be white. I also tried to change the theme by Widget.AppCompat.Light.ActionBar in Search.ActionMode but it does nothing.
There is an easy way to change the colors in Actionbar Use ActionBar Generator:
http://jgilfelt.github.io/android-actionbarstylegenerator/
and copy paste all file in your res folder and change your theme in Android.manifest file.
I have faced the same problem as yours. What I did is
I changed from
<!-- Base application theme. -->
<style name="Theme.Noteplus.Base.Brown" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
to
<!-- Base application theme. -->
<style name="Theme.Noteplus.Base.Brown" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
solve the problem. (Not exactly sure the reason behind)
(https://stackoverflow.com/a/50114013/72437)

Make ActionBar title uppercase

How do I make the ActionBar title uppercase? Some answers suggest putting <item name="android:textAllCaps">true</item> but this has no effect when I put it in the actionBar style or actionBar's titleTextStyle. It only has an effect when I put in in the AppTheme style but that makes a bunch of things in my app also in all caps which I don't want.
My styles:
<style name="AppTheme" parent="AppBaseTheme">
<!-- snip snip -->
<item name="android:actionBarStyle">#style/NewActionBar</item>
</style>
<style name="NewActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#color/text_pink</item> <!-- no effect -->
<item name="android:titleTextStyle">#style/NewActionBarTitle</item>
<item name="android:displayOptions">showHome|showTitle</item>
<item name="android:textAllCaps">true</item> <!-- no effect -->
</style>
<style name="NewActionBarTitle">
<item name="android:textSize">#dimen/tiny_text_size</item> <!-- no effect -->
<item name="android:textAllCaps">true</item> <!-- no effect -->
</style>
And why do the NewActionBar and NewActionBarTitle styles appear to have no effect no matter what I put in them? Is there something wrong with my styles or my action bar or what?
Edit: I've just deleted entirely the styles NewActionBar and NewActionBarTitle (and the reference to them in the AppTheme style) and the action bar looks completely the same. So something is broken. What could it be?
You need to set android:textAllCaps="true" on the text appearance for the action bar's title, rather than the action bar style itself or on your base activity theme.
<style name="AppTheme" parent="AppBaseTheme">
...
<item name="actionBarStyle">#style/Widget.MyApp.ActionBar.Solid</item>
</style>
<style name="Widget.MyApp.ActionBar.Solid"
parent="Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/TextAppearance.MyApp.Widget.ActionBar.Title</item>
</style>
<style name="TextAppearance.MyApp.Widget.ActionBar.Title"
parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textAllCaps">true</item>
</style>

Customizing the 'back' arrow color in Actionmode with appcompat-v7

My main theme is based on Theme.AppCompat.Light as follows:
<style name="core" parent="Theme.AppCompat.Light" >
<!-- Material, Yo!-->
<item name="colorPrimary">#color/theme_main_color</item>
<item name="colorPrimaryDark">#color/deep_purple</item>
<item name="colorAccent">#color/theme_accent_color</item>
<item name="android:navigationBarColor" tools:ignore="NewApi">?attr/colorPrimary</item>
<!-- Toolbar -->
<item name="theme">#style/my_toolbar_theme</item>
<item name="drawerArrowStyle">#style/my_drawer_arrow</item>
<!-- Actionbar -->
<item name="android:actionBarDivider">#null</item>
<item name="android:actionBarTabStyle">#null</item>
<item name="android:actionBarTabBarStyle">#null</item>
<!-- Contextual Actionbar -->
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">?attr/colorAccent</item>
<item name="actionModeStyle">#style/my_actionmode_style</item>
</style>
<style name="my_drawer_arrow" parent="Widget.AppCompat.DrawerArrowToggle" >
<item name="spinBars">true</item>
<item name="color">#color/theme_accent_color</item>
</style>
<style name="my_toolbar_style">
<item name="android:id">#id/toolbar</item>
<item name="android:minHeight">?attr/actionBarSize</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:background">?attr/colorPrimary</item>
<item name="android:elevation" tools:ignore="NewApi">5dp</item>
</style>
<style name="my_actionmode_style" parent="Widget.AppCompat.Light.ActionMode.Inverse" >
<item name="titleTextStyle">#style/my_actionmode_title_style</item>
<item name="subtitleTextStyle">#style/my_actionmode_subtitle_style</item>
</style>
<style name="my_toolbar_style.gradient">
<item name="android:background">#drawable/ab_gradient_bg</item>
</style>
<style name="my_toolbar_theme" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
<!-- Customize the toolbar here -->
</style>
<style name="my_actionmode_title_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
<item name="android:textColor">#color/std_white</item>
</style>
<style name="my_actionmode_subtitle_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Subtitle">
<item name="android:textColor">#android:color/white</item>
</style>
In actionmode I'd like to see white title/subtitles with a white back arrow. I've been able to set the title and subtitle text colors to white, but the back arrow remains black. This issue only occurs in places where I'm using the SupportActionbar and not the toolbar (the back arrow in toolbar is white).
This is my toolbar in ActionMode.
This is the actionbar in ActionMode. Same phone, same app, same themes, just a different activity.
I can't find anything in the themes that would determine this color. According to the source, the icon is #drawable/abc_ic_ab_back_mtrl_am_alpha, which is white, so something must be tinting it. Where does this black-ish color come from?
To customize this using AppCompat:
In your app level theme:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="actionModeCloseButtonStyle">#style/myclosebutton</item>
</style>
In the CloseButtonStyle:
<style name="myclosebutton" parent="Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:tint">#ff0</item> <!-- whatever color -->
</style>
I had the same problem and I have solved it by explicitly declaring the icon I want to use in the style:
<item name="android:actionModeCloseDrawable">#drawable/ab_back</item>
Where #drawable/ab_back is provided by me.
This is not ideal, as I would like to correctly set the style and let it work inheriting the right colours from the parent theme, without the need of declaring so specific details. But, I feel everything around the ActionBar, SupportActionBar, SherlockActionBar, ActionBarActivity, FragmentActivityWithASherlockSupportActionToolbar is SO broken and bad engineered that I'm happy to solve it with a workaround.
Try "colorControlNormal" Property Like given Below in your "NoActionBar Theme"
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="colorControlNormal">#android:color/white</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
I have best answer for this
Spannable text = new SpannableString( mode.getTitle());
text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorPrimaryDark)),
0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
mode.setTitle(text);

Change Color of Actionbar in Android

I am trying to change the background color of actionbar in my App but this is showing different on my app. Instead of coloring the actionbar the whole activity is color.
I am not sure why this is happening? I just want the main actionbar and settings actionbar colored.
Please check the screenshot.
Main Activity Map:
Preference Settings:
I also have transparent Actionbar with UP Navigation enabled for all my sub activities other than the main activity and preference settings activity.
I am not sure why it is showing like the above:
Here is style.xml (values-v14):
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:background">#FF5050</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar.Transparent" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
<!-- Activity Theme with transparent ActionBar -->
<style name="AppTheme.TransparentActionBar.Light" parent="#style/AppBaseTheme">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar.Transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<item name="android:actionBarTabTextStyle">#style/ActionBarTabTextStyle.Tabtheme</item>
<item name="android:actionBarDivider">#drawable/verticallinefordivder</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MapsLocation</item>
</style>
<style name="simpledialog" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
<style name="ActionBarTabTextStyle.Tabtheme" parent="#style/AppBaseTheme">
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#android:color/black</item>
</style>
<style name="ActionBarTabStyle.MapsLocations" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator</item>
</style>
<style name="myPreferenceTheme" parent="#style/AppBaseTheme">
<item name="android:textColor">#color/blue</item>
</style>
<style name="Widget.ActionButton" parent="#style/AppBaseTheme">
<item name="android:background">?android:attr/actionBarItemBackground</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:minWidth">56dip</item>
<item name="android:minHeight">?android:attr/actionBarSize</item>
</style>
</resources>
A little change and you action bar will be red:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#FF5050</item>
</style>
I have changed item in AppBaseTheme & AppTheme.Light.ActionBar .
Now you are good to go. let me know if it works however working at my end :P
You can try set custom view in action bar.
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(you_custom_layout);
I know this is not right answer to this question but if you want to edit your ActionBar, you can use this online Android Action Bar Style Generator.
At least you can create a style and check yours to find differences and learn how to edit your ActionBar.

Action Bar Overflow not using Three-Dot icon

I can't seem to determine why my overflow button is not the three-dot icon. It uses what seems to be a dropdown button (down arrow icon).
How come most of the applications I found uses the three-dot icon for the overflow. Here's my styles.xml so far.
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">#style/CncaActionBar</item>
</style>
<style name="FullscreenTheme" parent="android:style/Theme">
<item name="android:actionBarStyle">#style/CncaActionBar</item>
<item name="android:actionBarTabStyle">#style/CncaActionBarTab</item>
<item name="android:actionBarTabTextStyle">#style/CncaActionBarTabText</item>
<item name="android:windowBackground">#null</item>
<item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
<item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="CncaActionBarTab" parent="#android:Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/bg_tab</item>
</style>
<style name="CncaActionBarTabText" parent="#android:style/TextAppearance.Holo">
<item name="android:textColor">#android:color/white</item>
<item name="android:textAllCaps">true</item>
</style>
I've figured it out. I just needed to use Theme.Holo styling. This used the three-dot icon.

Categories

Resources