0

I'm a noob in android development and I need to set the background color of the ActionBar globally. The whole application will be the same ActionBar background. Can I make this by using AndroidManifest.xml, if yes how? Thanks!

Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109
  • 1
    AFAIK, you can declare a custom style for your ActionBar and define that in your manifest. Or you could create a base Activity class, from which all your other Activities will derive..and define the ActionBar background there. – Jade Byfield Jul 13 '13 at 19:31
  • Please,can you explain widely?How I can understand declare a custom style for your ActionBar? – user2579806 Jul 13 '13 at 19:39
  • Are you using the native ActionBar or the ActionBarSherlock library? – Jade Byfield Jul 13 '13 at 19:44

2 Answers2

0

To make global variables...

  1. Make a new class and add your variables (Add whatever value you need in this class)

    package com.srr.yourpackage;
    
    public class GlobalVariables extends Application{
    
        private int someVar;
    
        public int getSomeVar(){
            return someVar;
        }
        public void setSomeVar(int a){
            someVar = a;
        }
    
    }
    
  2. Add the reference of this file to your Manifest inside the application tag.

    <application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:name =".GlobalVariables">
    <activity.....
    </application>
    
  3. Use it inside any of your classes.

    public class yourNewClass extends Activity
    {
         GlobalVariables globalVar;
    
         protected void onCreate(Bundle savedInstanceState) {
         // TODO Auto-generated method stub
         super.onCreate(savedInstanceState);
         setContentView(R.layout.yourLayout);
         globalVar = (GlobalVariables) getApplication();
         int yourInt = globalVar.getSomeVar(); //Call upon anything you need in the activity of your choice.
         }
     }
    

Or if you only need just Action Bar, use this topic

Community
  • 1
  • 1
Alexey
  • 3,607
  • 8
  • 34
  • 54
0

I'd rather prefer to make a theme and customize each activity, or the application in the manifest file. When I develop apps, I use this tool to generate the UI:

Android Action Bar Style Generator

Tobias Moe Thorstensen
  • 8,861
  • 16
  • 75
  • 143