Home > Android Tutorial, TitleBar > How to set icon for title bar in Android?

How to set icon for title bar in Android?

In android we have the facility to set a icon for title bar.

see the below image here the title bar contains only title.
Title name is Iconic Memorey

How to set icon in title bar?.
use this.

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

requestWindowFeature(Window.FEATURE_RIGHT_ICON);
setContentView(R.layout.main);
setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON, R.drawable.icon);
}

By using this code we can get the output like below image

Advertisements
  1. Lazar
    April 13, 2010 at 7:44 am

    Seem to left and very small. If icon.png is 32×32, what I see is not original size

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: