in styles.xml running Android 5.0 lollipop
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:statusBarColor">@color/primary</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColor">@color/secondary_text</item>
<item name="android:navigationBarColor">@color/primary_dark</item>
</style>
when I build it and run it, I only get the status bar colored with the colorPrimaryDark while the toolbar remains black. How do I make it turn to colorPrimary?
This is what I'm currently getting
https://www.dropbox.com/s/alp8d2fhzfd5g71/Screenshot_2015-02-25-21-13-01.png?dl=0
in your style. xml in values folder this will change your action bar color.. Replace #666666 with your selected color code for title background color and replace #000000 for your title text color.
All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.
UPDATE:
Make a new file in your layouts folder called tool_bar.xml and paste the following code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/ColorPrimary"
android:elevation="2dp"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
xmlns:android="http://schemas.android.com/apk/res/android" />
Add these colors in your color.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ColorPrimary">#00897B</color>
<color name="ColorPrimaryDark">#00695C</color>
</resources>
This is the code for your styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>
You should add the folowing code to your MainActivity.xml file:
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
This way worked for me!
This should give you the actionbar that looks like the one below a result
If you want to change Action bar color of Android App. Just take care of these 3 files
color.xml ( Defining action bar color )
<color name="colorPrimary">#4613AC</color>
<color name="colorPrimaryDark">#4613AC</color>
style.xml ( Defining style of action bar )
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Manifext.xml ( Applying action bar to App )
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="BarCode Scanner Generator"
android:largeHeap="true"
android:theme="@style/AppTheme" > //This Line apply AppTheme to your app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With