Java tutorial
//package com.java2s; /* Copyright 2012 lewica.pl Licensed under the Apache Licence, Version 2.0 (the "Licence"); you may not use this file except in compliance with the Licence. You may obtain a copy of the Licence at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence. */ import android.app.Activity; import android.view.View; import android.view.ViewParent; public class Main { /** * Sets custom title background colour, * see http://stackoverflow.com/questions/2251714/set-title-background-color * @param colour */ public static void setApplicationTitleBackgroundColour(int colour, Activity activity) { View titleView = activity.getWindow().findViewById(android.R.id.title); if (titleView == null) { return; } ViewParent parent = titleView.getParent(); if (parent == null || !(parent instanceof View)) { return; } View parentView = (View) parent; parentView.setBackgroundColor(colour); } }