Action Bar icon as up enabled not the title

android, android-actionbar

Solution

The title is clickable together with the icon since Android 4.2.2. WhatsApp uses a custom view to display a two line title. This disables the title click along the way. You can do it the same way:

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.ab_title);

TextView title = (TextView) findViewById(android.R.id.text1);
title.setText("Title");

/res/layout/ab_title.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/TextAppearance.Sherlock.Widget.ActionBar.Title"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:ellipsize="end"
    android:gravity="center_vertical" />

Problem

How to make app icon as up enabled in actionbarsherlock (not the title only icon) like in whats app.

Original source