2

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!

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158

3 Answers3

1

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

Gabriel Negut
  • 13,860
  • 4
  • 38
  • 45
  • 1
    Actually, I have read it and I applied what's in there... Although I don't understand why we need to provide a custom style given we have the `window_title` layout. What does the custom_style add to the equation? – Amokrane Chentir Jun 01 '11 at 14:55
0

set the layout_height as wrap_content or fill_parent of the linear layout

and then try it

Pratik
  • 30,639
  • 18
  • 84
  • 159
  • I want to set a custom height. Also when providing an image background, the image is streched to fill up the width so the proportions are not the same as the original one. – Amokrane Chentir Jun 01 '11 at 14:59
-1

you can use :

getWindow().setLayout(50, 50);

of course this code use to set width and hiegth of window

HamidReza
  • 1,726
  • 20
  • 15