Xamarin – Adding Custom Title Bar in Android

In this post, we would see how to add your custom Title Bar, or Action Bar in Android.

In the following image, the Greyish Rectangle with Text is the default TitleBar from Android. We would replace this with our custom design in this post.


First of all add a Layout to the Layout folder.



Now in the layout, have a TextView to display the text as the Title.


Now, we would add a Style.xml to Values folder.


In this XML, you can define your control styles and link it to the control. Here we are doing it for the LinearLayout.


The image gradient_tile is added to the Drawable folder.


Now that we have added the style, let’s link it to the LinearLayout as follows.


Now, in Main.axml; which is our Main Activity’s layout. We would add the include tag for adding sub layouts.


Let’s run the application. And you would see our custom made title bar with the default one. How do we disable the default title bar? Well you could do it by changing the theme in AndroidManifest.xml


In AndroidManifest.xml, add the attribute android:theme with the following value.


Now run the application again, and you would see that our custom Title bar is displayed.


Hope this post helps, thanks for reading.


Full Source Code: Click Here.