Android Tech

The more we share, the more we get

Title (Part 5) – Create a transparent title in Android


Sometime, may be you want your application be transparent from head to tail and so that, the title should not have its default background color or image. To do this, you have to create a custom theme for your application like this:

<?xml version=”1.0″ encoding=”utf-8″?>
<resources>

<style name=”title_background”>
<item name=”android:background”>@android:color/transparent</item>
</style>

<style name=”custom_titlebar”>
<item name=”android:windowTitleBackgroundStyle”>@style/title_background</item>
<item name=”android:windowTitleSize”>35dp</item>
<item name=”android:windowBackground”>@drawable/bk</item>
</style>

</resources>


In style “title_background”, you define that this title have transparent background and you apply it to your custom theme.

In style “custom_titlebar” (custom theme), you set background image for your application throught attribute “android:windowBackground”

Next, apply custom theme to your application

<application android:icon=”@drawable/icon” android:label=”@string/app_name”
android:theme=”@style/custom_titlebar”>

The final result will like this:

You can download source code here

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: