Geek
Geek

Reputation: 8320

How to add logo on top-left corner of each screen in android application?

I want to add an application logo on each screen of an application.
Is there any way to make such centralized change from a single place instead of adding logo in layout file for each screen?

Upvotes: 0

Views: 5610

Answers (4)

Bhavesh Jethani
Bhavesh Jethani

Reputation: 3875

you can specifies your application icon in manifest. in activity tag

in that android:icon="@drawable/your_logeHere" that will show in title bar.

Upvotes: 0

Muz
Muz

Reputation: 5980

If you're targeting an API over 14 (Ice Cream Sandwich),

getActionBar().setLogo(R.drawable.your_logo_name);

You'll have to do this for every Activity. What I usually do is to set one "BaseActivity" which I extend other activities from. This becomes helpful especially later on when standardizing other things like common functions and settings.

Upvotes: 1

Arun C
Arun C

Reputation: 9035

Use Action Bar to make such centralized change from a single place instead of adding logo in layout file for each screen.

enter image description here

'1' is the palce for the app icon, which establishes your app's identity. It can be replaced with a different logo or branding if you wish. Important: If the app is currently not displaying the top-level screen, be sure to display the Up caret to the left of the app icon, so the user can navigate up the hierarchy.

You can also add additional Navigation here.

Upvotes: 0

Vivek Kumar Srivastava
Vivek Kumar Srivastava

Reputation: 2158

as Raghav said you can use ActionBar. See this example for Actionbar

If you don't want to use action bar then you can create a single layout like with name "logo.xml"

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@drawable/icon_image"/>

then use this layout file in any of your layout by including this layout file like

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical">

    <include layout="@layout/logo"/>
    <!--your other code-->
    </LinearLayout>

Upvotes: 0

Related Questions