androidandroid-layoutandroid-titlebar

Android - Customizing the title bar


I want to customize the title bar for an Android application. I have the following layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="80dp" <!-- Problem here -->
    android:gravity="center_vertical"
    >

    <ImageView
        android:id="@+id/header"
        android:background="@drawable/windowtitle"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

</LinearLayout>

I also have a the following code in the targeted activity:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.home);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
        ... 
}

I don't understand why the height of the title bar doesn't change when changing the android:layout_height value.

Did I miss something?

Thanks!


Solution

  • According to this article, you should create a custom style for this. See if it works for you.