user4449745
user4449745

Reputation:

How to change color of bar in Android App?

I'd like to change color of bar when I use this style:

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light" >
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
    </style>

For example it should looks like system calculator in Android 5, I mean bar on the top is blue.

Upvotes: 1

Views: 106

Answers (3)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363477

Use the appCompat21 and just set this style:

<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>
</style>

More info here.

Upvotes: 0

keshav kowshik
keshav kowshik

Reputation: 2374

Are you speaking about tool bar. If yes then implement the following xml in your project:

?xml version="1.0" encoding="utf-8"?>
<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/appBar"
    android:background="@color/colorPrimary"
    app:theme="@style/MyCustomTheme"

    android:layout_width="match_parent"
    android:layout_height="50dp">

</android.support.v7.widget.Toolbar>

In activity extend your activity to ActionBarActivity, then in onCreate() use the following code:

ToolBar toolbar = (Toolbar) findViewById(R.id.appBar);
        setSupportActionBar(toolbar);

Make sure you give blue color for colorPrimary attribute in colors.xml file or you can directly give blue color value if you are not using colors.xml file.

Upvotes: 0

Moinkhan
Moinkhan

Reputation: 12932

you can use

<item name="background">@color/actionbar_background_color</item>

Upvotes: 1

Related Questions