1

I have a listactivity with iconified text which I'm giving a custom title. Here's my custom_style.xml:

<resources>
    <style name="CustomWindowTitleBackground">
        <item name="android:background">#222222</item>
    </style>

    <style name="CustomTheme" parent="android:Theme">
        <item name="android:windowTitleSize">50dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style> 
</resources>

Here's the layout for the title, window_title.xml:

<?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="50dip"
    android:gravity="center_vertical"
    android:paddingLeft="10dip"
    android:background="#222222">

    <ImageView
        android:id="@+id/header"
        android:src="@drawable/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>

I set the new title style in onCreate:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    // if it wasn't a listactivity, here I'd use
    // setContentView(R.layout.main);

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

    browseToRoot();
}

My problem is that the styled title bar appears at the correct size and with the correct background colour (taken from custom_style.xml) but eveything in window_title.xml is ignored. The rest of the listadapter still works fine. In a very similar question here: Custom title with image it says setFeatureInt must come before super.onCreate but either way my result is the same.

I've tried replacing the imageview with a nice simple textview, but the entire window_title.xml seems to be ignored. Any ideas where I'm going wrong? Many thanks, Baz.

Community
  • 1
  • 1
Barry
  • 1,258
  • 3
  • 13
  • 27
  • Here: [link](http://stackoverflow.com/questions/6831325/custom-title-of-preferenceactivity-problem) a very similar problem happens with a PreferenceActivity - mine's a ListActivity - is there a problem using this technique with anything other than a vanilla Activity? EDIT: No, I applied exactly the same thing to a regular Activity in my app and that too has a blank space where the nice new title should be (Grrr). – Barry Aug 24 '11 at 11:30
  • RE-EDIT: Correction, that works on a regular Activity, but fails on a ListActivity - poss because there's no line like this: setContentView(R.layout.main); ??? – Barry Aug 24 '11 at 11:36

0 Answers0