Skip to content Skip to sidebar Skip to footer

How Can I Create A Custom Titlebar For All Of My Activities?

I have seen many examples of creating a custom titlebar: http://zaman91.wordpress.com/2010/03/16/android-how-to-add-custom-title-bar/ Is there a simpler way of doing this? I think

Solution 1:

Why not use an include? Put the design of your standard titlebar into a layout XML file, and then include it in each activity layout:

<include layout="@layout/my_title_bar" />

And then create my_title_bar.xml to contain the contents of the bar.

If you have clickable views in the title bar you'll need a little code, but you could subclass Activity to provide click methods.

Solution 2:

Create an Activity base class and write the code to draw the custom title bar. Derive your Activities from this. If you want the title text of your title bar to change, you could also write a setter method in your Activity base class.

Post a Comment for "How Can I Create A Custom Titlebar For All Of My Activities?"