I have an application in which the toolbar is overdrawn several times, the cause of this is the use of an additional background, if I remove this background, the problem is solved but the color of the toolbar is black and that's not what i want, the solution i think is to override the material background color instead of adding a new one (because it has already taken a background from the material theme) but i don't know how to do it.
Toolbar:
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" /> <!-- causing overdraw problem -->
</com.google.android.material.appbar.AppBarLayout>
Theme :
<style name="Theme.MyApp" parent="Base.Theme.MyApp">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/color_cape_cod</item>
<item name="colorPrimaryVariant">#color/color_mine_shaft</item>
<item name="colorOnPrimary">#color/color_white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/vivid_cerulean</item>
<item name="colorSecondaryVariant">#color/color_teal</item>
<item name="colorOnSecondary">#color/color_black</item>
<!-- background -->
<item name="android:colorBackground">#color/color_mine_shaft_dark</item>
<item name="colorOnBackground">#color/color_white</item>
<!-- surface -->
<item name="colorSurface">#color/color_black</item>
<item name="colorOnSurface">#color/color_white</item>
<!-- Customize your theme here. -->
<item name="imageTintColor">#color/color_white</item>
<item name="toolbarTextColor">#color/color_white</item>
<item name="lineHighlightColor">#color/color_tundora</item>
<item name="android:navigationBarColor">#color/color_black</item>
</style>
<style name="CustomRunButton" parent="ThemeOverlay.MaterialComponents">
<item name="colorSecondary">#color/color_raven</item>
</style>
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="android:textColorPrimary">#color/color_white</item>
</style>
<style name="Base.Theme.MyApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="alertDialogTheme">#style/AppCompatAlertDialogStyle</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
<item name="android:windowBackground">?android:colorBackground</item>
<item name="android:windowLightStatusBar" tools:ignore="NewApi">?attr/isLightTheme</item>
</style>
<style name="BottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">#style/BottomSheetStyle</item>
</style>
<style name="BottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">#android:color/transparent</item>
</style>
Related
I am using an image button on ListView which shows a popup menu when clicked.
But the problem is that items are not visible.
This is how menu looks.I can see white text on menu in this image but on mobile screen it is invisible.
This is styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:colorBackground">#color/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:textColorSecondary">#fcfcfc</item>
<item name="android:actionMenuTextColor">#color/black</item>
</style>
<style name="itemTextStyle.AppTheme" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/colorPrimary</item>
</style>
<!-- LoginCreateText -->
<style name="LoginCreateText">
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:layout_margin">2dp</item>
</style>
<!-- LoginCreateTextButton -->
<style name="LoginCreateTextButton">
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:layout_margin">2dp</item>
<item name="android:clickable">true</item>
</style>
<style name="HintText">
<item name="android:textSize">0dp</item>
</style>
<style name="FAB">
<item name="android:layout_margin">0dp</item>
<item name="fabSize">normal</item>
<item name="rippleColor">#android:color/white</item>
<item name="backgroundTint">#color/colorAccent</item>
</style>
<style name="ListItemText">
<item name="android:textColor">#color/light_black</item>
<item name="android:textSize">#dimen/list_item_text_size</item>
<item name="android:layout_margin">2dp</item>
</style>
</resources>
This is themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Button.Login" parent="android:Widget.Button">
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:layout_gravity">center</item>
<item name="android:background">#color/colorPrimary</item>
</style>
<style name="Toolbar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:itemTextAppearance">#style/itemTextStyle.AppTheme</item>
<item name="android:background">#color/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/white</item>
</style>
<style name="CustomTheme.Dialog" parent="Theme.AppCompat.Light.Dialog"/>
</resources>
This is the menu which I am trying to display.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
app:popupTheme="#style/itemTextStyle.AppTheme">
<item
android:id="#+id/action_edit"
android:title="#string/action_edit" />
<item
android:id="#+id/action_delete"
android:title="#string/action_delete"/>
<item
android:id="#+id/action_assign"
android:title="#string/action_assign"
android:checkable="true"/>
<item
android:id="#+id/action_mark"
android:title="#string/action_mark"
android:enabled="false"/>
</menu>
This is layout file for Quiz Fragment.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl_fragment_quiz_lists"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey"
app:popupTheme="#style/itemTextStyle.AppTheme"
tools:context=".ui.fragments.QuizFragment">
<include layout="#layout/single_active_list" />
<ListView
android:id="#+id/list_view_active_lists"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fab"
style="#style/FAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="showAddQuizDialog"
android:src="#drawable/ic_add_quiz"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp">
<!--app:rippleColor="#android:color/white" /> -->
</android.support.design.widget.FloatingActionButton>
</RelativeLayout>
This is the layout file of the activity in which this fragment is displayed.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Toolbar" />
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Toolbar" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
I have tried many solutions that were asked before ( all were about toolbar menu) but none worked for me.
I defined a new style in styles.xml
<style name="itemTextStyle.AppTheme" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/colorPrimary</item>
and included it in AppTheme which didn't work.then I included it in toolbar style, menu layout, QuizFragment layout but items were still invisible.How to change the background color or item color of menu to fix this, any one will work.
Try this
style.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat">
<item name="android:actionOverflowButtonStyle">#style/OverflowButton</item>
<item name="actionOverflowButtonStyle">#style/OverflowButton</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="actionOverflowMenuStyle">#style/OverflowMenu</item>
<item name="actionBarDivider">#null</item>
<!-- OverFlow Menu Text Color -->
<item name="android:textColor">#color/black</item>
</style>
<!-- OverFlow menu Styles -->
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:divider">#color/black</item>
<item name="android:dividerHeight">1dp</item>
<item name="android:background">#color/white</item>
</style>
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<!-- Required for pre-Lollipop. -->
<item name="overlapAnchor">false</item>
<!-- Required for Lollipop. -->
<item name="android:overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">4.0dip</item>
</style>
and define theme for Activity in AndroidManifest.xml
<activity
android:name=".YourActivityName"
android:theme="#style/CustomActionBarTheme"/>
I am using only two themes files (for dark, and day)
Theme.MaterialComponents.DayNight.NoActionBar.Bridge
inside them, I have only items of the same name for both day and night, but in different colors. Found (after experimenting)...that this line is a game-changer in my case (same problem as yours) for title and menu to be white, while at the same time text on popup menu is black
<item name="android:textColorSecondary">#android:color/white</item>
here is the whole file, I used only this, and trying to not hard code anything.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Ch+++itche+++++" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<!-- Primary brand color. -->
<item name="android:textColorSecondary">#android:color/white</item>
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryVariant">#color/primaryDarkColor</item>
<item name="colorOnPrimary">#color/primaryLightColor</item>
<item name="colorOnSurface">#color/primaryColorWhiteDay</item>
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
That is all,
Happy coding,
Nenad
I'm trying to change the background color of my ActionBar as well as the title color. I must say I am using the support library.
My styles are as follows.
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/red_300</item>
<item name="android:background">#color/red_300</item>
<item name="colorPrimary">#color/red_300</item>
<item name="android:titleTextStyle">#style/AppTheme.ActionBar.Title</item>
</style>
<style name="AppTheme.ActionBar.Title" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/red_700</item>
<item name="android:textColorPrimary">#00FF00</item>
</style>
And in styles-v21
<style name="AppTheme.ActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/red_300</item>
<item name="android:background">#color/red_300</item>
<item name="colorPrimary">#color/red_300</item>
<item name="android:colorPrimary">#FF0000</item>
<item name="android:colorAccent">#FF0000</item>
<item name="android:titleTextStyle">#style/AppTheme.ActionBar.Title</item>
</style>
<style name="AppTheme.ActionBar.Title" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:colorPrimary">#FFFF00</item>
<item name="android:colorAccent">#FFFF00</item>
<item name="android:textColor">#color/red_700</item>
<item name="android:textColorPrimary">#00FF00</item>
</style>
As you guys might see by the amount of attemps to change it, I am already losing my mind. Any clues as to how I can change the ActionBar background and it's title color?
I must note that I am trying this on Android 6.
In the ToolBar creation (xml), setting the app:theme fixed it. Specifying a theme there with it's colorPrimary changed the background of the ActionBar without affecting the base theme.
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
and the theme:
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
</style>
I want to change the ripple color of the DrawerToggle, but I couldn't find any way to do so. My style file looks like this. This changes the other menu items backgrounds but doesn't work for the back arrow. How do I change the ripple color of the Drawer Arrow
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#FF0000</item>
<item name="colorPrimaryDark">#660000</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:textColorSecondary">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:actionBarItemBackground">#drawable/my_ripple_borderless</item>
<item name="selectableItemBackground">#drawable/my_ripple</item>
<item name="android:selectableItemBackground">#drawable/my_ripple</item>
<item name="listChoiceBackgroundIndicator">#drawable/my_ripple</item>
<item name="android:listChoiceBackgroundIndicator">#drawable/my_ripple</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<!--<item name="spinBars">false</item>-->
<item name="color">#color/drawer_icon_color</item>
</style>
Add this style
<style name="AppTheme.Toolbar">
<item name="colorControlHighlight">#color/colorControlHighlight</item>
</style>
to your toolbar
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="#style/AppTheme.Toolbar"
app:popupTheme="#style/AppTheme.PopupOverlay" />
Original answer:
https://stackoverflow.com/a/30676995/2311651
I am using Theme.AppCompat.Light.NoActionBar theme. I am getting a white background for popup menu and also the color of menu item is white that makes it invisible. I tried many solutions with no success.
This is my styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionMenuTextColor">#000000</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:textAppearanceLargePopupMenu">#style/myPopupMenuTextAppearanceLarge</item>
<item name="android:textAppearanceSmallPopupMenu">#style/myPopupMenuTextAppearanceSmall</item>
<!-- Customize your theme here. -->
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
<item name="android:textColor">#000000</item>
<item name="android:textSize">12sp</item>
</style>
<style name="myPopupMenuTextAppearanceSmall" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small" tools:ignore="NewApi">
<item name="android:textColor">#000000</item>
<item name="android:textSize">15sp</item>
</style>
<style name="myPopupMenuTextAppearanceLarge" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large" tools:ignore="NewApi">
<item name="android:textColor">#000000</item>
<item name="android:textSize">25sp</item>
</style>
This is the toolbar
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/toolbar"
android:elevation="8dp"
app:theme="#style/AppTheme"
app:title="Troll Cricket" />
Add these lines to your Toolbar.xml file.
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
This will allow you to have a dark toolbar and light-themed overflow menu.
I'm trying to make an appcompat theme but the color isn't working, and the icon won't show either... maybe im missing something. Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<color name="background_test">#410000</color>
<color name="font_general">#ffffff</color>
<style name="MyTheme"
parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="AudioFileInfoOverlayText">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingBottom">2dp</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:textSize">18sp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:icon">#drawable/ic_launcher</item>
<item name="icon">#drawable/ic_launcher</item>
<item name="background">#color/background_test</item>
<item name="android:background">#color/background_test</item>
</style>
</resources>
What should i add to make it work?
EDIT:
It won't work with a toolbar either... After i set:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
It will lose all the user defined theme and will only get the parent theme... Here are my xmls (Yes i have a lot of redundant/test values as i wanted to try everything)
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
background="?attr/colorPrimary"
app:popupTheme="#style/MyActionBarStyle"
android:background="?attr/colorPrimary"
app:theme="#style/MyActionBarStyle"
/>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<color name="background_test">#410000</color>
<color name="font_general">#ffffff</color>
<!-- general styles for the action bar -->
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="actionBarStyle">#style/MyActionBarStyle</item>
<item name="android:panelColorBackground">#color/background_test</item>
<item name="android:headerBackground">#color/background_test</item>
<item name="android:colorBackground">#color/background_test</item>
<item name="android:backgroundSplit">#color/background_test</item>
<item name="backgroundSplit">#color/background_test</item>
<item name="colorAccent">#color/background_test</item>
<!-- Here we setting appcompat’s actionBarStyle -->
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">#color/background_test</item>
<item name="colorPrimaryDark">#color/background_test</item>
</style>
<style name="MyActionBarStyle">
<item name="colorAccent">#color/background_test</item>
<!-- Here we setting appcompat’s actionBarStyle -->
<item name="android:panelColorBackground">#color/background_test</item>
<item name="android:headerBackground">#color/background_test</item>
<item name="android:colorBackground">#color/background_test</item>
<item name="android:backgroundSplit">#color/background_test</item>
<item name="backgroundSplit">#color/background_test</item>
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">#color/background_test</item>
<item name="colorPrimaryDark">#color/background_test</item>
<item name="android:background">#color/background_test</item>
<item name="background">#color/background_test</item>
</style>
<style name="AudioFileInfoOverlayText">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingBottom">2dp</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:textSize">18sp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1</item>
</style>
</resources>
Screenshot:
http://i.imgur.com/4iohVwP.png
New EDIT:
It won't work from the code either...
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
ActionBar test=getSupportActionBar();
test.setLogo(R.drawable.ic_launcher); //this is the only one working...
test.setBackgroundDrawable(new ColorDrawable(0x410000));
test.setDisplayShowTitleEnabled(false);
test.setDisplayShowTitleEnabled(true);
EDIT:
There are some bugs reported for the new Appcompat-v7, this is probably a bug:
http://code.google.com/p/android/issues/detail?id=77763&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
If you are using Toolbar then your actionBarStyle is not used.
You need to style Toolbar directly:
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="..."
android:background="..."
app:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:titleTextAppearance="..."
app:subtitleTextAppearance="..." />
There are more attributes you can customize, these are just examples.
I'm not sure why getSupportActionBar().setBackgroundDrawable(...) doesn't work for you, I've just tried it in various places and it works fine.
It is an example:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/my_color</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#color/my_darker_color</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#color/accent</item>
<!-- appcompat’s actionBarStyle -->
<item name="actionBarStyle">#style/MyActionBarStyle</item>
</style>
Also I suggest you using the new Toolbar.
You can find more info here:
https://chris.banes.me/2014/10/17/appcompat-v21/
One solution to get the AppCompatActivity to use the primary theme color on the Action Bar for all api levels is to declare the colors in the same theme like this:
<style name="Theme.Custom" parent="Theme.AppCompat">
<!--API < 21 -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="colorButtonNormal">#color/colorButtonNormal</item>
<!-- 21 < API this is probably not needed, included for illustration -->
<item name="android:colorPrimary" tools:ignore="NewApi">#color/colorPrimary</item>
<item name="android:colorPrimaryDark" tools:ignore="NewApi">#color/colorPrimaryDark</item>
<item name="android:colorAccent" tools:ignore="NewApi">#color/colorAccent</item>
<item name="android:colorButtonNormal" tools:ignore="NewApi">#color/colorButtonNormal</item>
</style>
note: remember to remove the theme declared in values-v21 for this to work