0

Possible Duplicate:
How do I programmatically set the background color gradient on a Custom Title Bar?

I want to use gradient color in application title bar. How can I do it?

Thanks in advance.

Community
  • 1
  • 1
Zahid Habib
  • 675
  • 3
  • 12
  • 22
  • 1
    try this http://stackoverflow.com/questions/6115715/how-do-i-programmatically-set-the-background-color-gradient-on-a-custom-title-ba – Ajay Jan 26 '12 at 07:19

1 Answers1

6

All people are trying to use Custom title for this requirement.

I achieved this without using custom title. Just use below code in your activity's onCreate() after setContentView().

GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {Color.RED,Color.GREEN});
View title = getWindow().findViewById(android.R.id.title);
View titleBar = (View) title.getParent();
titleBar.setBackgroundDrawable(gd);

Enjoy with above code. Below image is screen shot of my app with gradient color as title bar background.

Gradient Color as Background of title bar

Yugandhar Babu
  • 9,911
  • 9
  • 39
  • 65