Reputation: 8320
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
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
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
Reputation: 9035
Use Action Bar to make such centralized change from a single place instead of adding logo in layout file for each screen.
'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
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