How to change the accent color in an Android application from blue to another

All I want to do is change the accent color of my Android app, but it's hard for me to determine how to do it. The default value for android is now blue, but I want to make it orange.

By accent color, I mean the accent of the navigation tabs, the color that is highlighted when you get to the lists, the accent color in pop-up dialogs, etc.

I use actionbarsherlock if that matters.

Here is the image. I would like to change the color of this blue accent throughout the application: enter image description here

+5
source share
2 answers
+2

, , , Google AppCompat, , . , , Android 2.2.1.

  • ( , Android Studio).

    app.graddle ( app).

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

  1. styles.xml. , . , , Android .

    colorAccent - , .

    <!-- 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>
    

    Android

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

    1. Activity/ActionBarActivity AppCompatActivity .

      public class MainActivity extends AppCompatActivity
      {
           ....
      }
      

      , - AppCompatActivity. , , :)


      1. AppCompat

        <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à! :) Accent.

+2

All Articles