Custom title with image

Posted by Alex Volovoy on Stack Overflow See other posts from Stack Overflow or by Alex Volovoy
Published on 2010-01-18T15:20:08Z Indexed on 2010/04/29 1:17 UTC
Read the original article Hit count: 461

Filed under:
|
|

Hi all, i'm creating custom title for activity by disabling standard one and managing everything myself. I wonder if it's possible to replace/theme standart title to my needs.

I can customize size, background image, and text via themes by changing windowXYZStyle items.

The only thing i couldn't find - how i can add image instead of text. I've tried requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) and assign custom layout - but it doesn't seems to work.

EDIT : Here is a report of testing suggestions, code is below - result - image view is not showing up.

Activity

public class SettingsActivity extends PreferenceActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settings);

    }
}

XML :

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="26dip"
    android:paddingLeft="5dip"
    android:background="@drawable/titlebar_bg"
    android:layout_gravity="left|center"
>
    <ImageView
        android:id="@+id/logo"
        android:src="@drawable/title_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

© Stack Overflow or respective owner

Related posts about android

Related posts about window