So lets start with a custom_title_bar.xml >created in /res/layout directory. Here ImageView hold the icon and TextView holds the title bar text. I did not set any background color here which i will set in my custom styles. But keep a layout height = 45dip which will be the title bar height.
Next Step -
Now create a custom_titlebar_style.xml in /res/values folder. Here I made a custom title background color style which I used like Facebook Title color [#3b5998]. And create another title bar size style of “45dip”. Now we are done.
Now add this custom style name in Manifest.xml file in
We just need to do add 2 lines of code in onCreate() method. First add first line before setContentView(R.layout.your_layout.xml) method. Later set the integer value for a feature using the value (a layout xml file) of the custom title bar. Below shows -
Here how the custom title bar should look like. I have used Facebook style theme color which i like most -
And we are done. One thing, if we want no title bar? Specially game apps like it. Use the following code before calling setContentView() method-
/**
* If you want no title bar then use the following code:
* requestWindowFeature(Window.FEATURE_NO_TITLE);
* getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
* WindowManager.LayoutParams.FLAG_FULLSCREEN);
**/
You can get the Eclipse project here [API v8] – https://github.com/jnoras/com.jnoras.android