Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the accent color on my Android app from blue to something else

All I want to do is change the accent color of my android app, but I'm having a tough time figuring out how to do that. The default for android is blue now, but I want to make it orange.

By accent color, I mean the accent of navigation tabs, the color that highlights when you hit lists, the accent color in pop up dialogs, etc.

I'm using actionbarsherlock if that matters.

Here is an image. I'd like to change the color of that blue accent throughout the app: enter image description here

like image 896
jacosta Avatar asked Aug 02 '12 15:08

jacosta


People also ask

How do you change the color of accents on Android?

Go to Settings->About Phone->Build Number and tap on it 7 times. You will get the message “you are now a developer” and developer options will get enabled. Go to Settings->System->Developer options–>Scroll down to accent colors. Now, choose the accent color that you want to enable and you are done.

How do you change the color of your apps on Android?

Search for and select Open App, and then, on the New Shortcut page, tap Choose. Locate the app whose appearance you want to change. Back on the New Shortcut page, you'll see the app name; tap More (three dots), change the app's name, tap its icon, select Color, and choose a new color.

What is accent color in app?

The accent color is used more subtly throughout the app, to call attention to key elements. The resulting juxtaposition of a tamer primary color and a brighter accent, gives apps a bold, colorful look without overwhelming the app's actual content.

How can I change the font color of my Android app name?

For this, you need to find the AnroidManifest. xml file. Option2: Directly go to app -> src -> main -> res -> values -> strings. xml and change the name to whatever you want.


2 Answers

It's been some time since you asked this question but now that google has released a new AppCompat version you can do what you want to achieve quite simply. The answer I'm giving you is inspired from android developer blog support library 2.2.1.

  1. Add the support library to your project (I am assuming you are using Android Studio).

    For that add these lines to the app.graddle file (assuming your module is named app).

    dependencies {
        compile 'com.android.support:appcompat-v7:22.2.0'
    }
    

  1. Set the theme of your application

    These lines are to be added to your styles.xml file. As you can see there are a few items in this style. If you want to know what element they correspond to go check customize android status bar with material.

    colorAccent is the color you want to change in the first place.

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primaryDark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:navigationBarColor">@color/navigationBarColor</item>
    </style>
    

    You will also need to set your application theme in the Android manifest

    <application
        android:theme="@style/AppTheme" >
    
        ...
    
    </application>
    

  1. Change From Activity / ActionBarActivity to AppCompatActivity in your classes.

    public class MainActivity extends AppCompatActivity
    {
         ....
    }
    

    You will probably need to change some methods due to the AppCompatActivity. Look at the video in the first link to better understand that :)


  1. Change your widgets to the AppCompat ones

    <LineareLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/text"
            android:text="@string/hello_world"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_start"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/btn_start" />
    
    </RelativeLayout>
    

Et voilà ! That's it you're all set :) You can now change the Accent color easily.

like image 146
WannaGetHigh Avatar answered Oct 19 '22 23:10

WannaGetHigh


You're going to want to use state layout lists.

http://developer.android.com/reference/android/content/res/ColorStateList.html

You might need to make one of these for each of the widgets that is going to have a new default selected color.

like image 32
Michael Avatar answered Oct 19 '22 23:10

Michael