0

I'm targeting API level 9.

My main activity's top bar looks like this:

AndroidManifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dabestappsever.bigtext" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name">
        <activity
            android:name="com.dabestappsever.bigtext.MainActivity"
            android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        ... MORE CODE HERE ...
    </application>

</manifest>

res/menu/menu_main.xml looks like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
</menu>

I tried adding @drawable/logo to the Manifest, but no luck.

How do I add a custom icon with a custom title next to it for my main activity?

Novice coder
  • 163
  • 1
  • 8

3 Answers3

0

Try inserting these 2 lines inside the Activity open tag

android:icon="@drawable/<icon>"
android:label="@string/<title>"
Patrick Sava
  • 126
  • 4
  • Didn't exactly work. No icon, and while the main activity title changed, so did the app label itself. That is, when you look at the app name on your phone, it says what I typed for `` – Novice coder Feb 26 '15 at 23:02
  • I put the code in `` while leaving `` alone. It changed the app's "label," and didn't show my logo. – Novice coder Feb 26 '15 at 23:20
0

To set icon in ActionBar add getSupportActionBar().setIcon(R.drawable.icon); in onCreate() method of your activity.

public class MainActivity extends ActionBarActivity{

@Override
public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);  //your layout

    getSupportActionBar().setIcon(R.drawable.icon); //this will set icon in actionbar
    ....
    ....
    }
}

And to set title in actrionbar write following in tag of manifest file

android:label="@string/activity_title"
Apurva
  • 7,871
  • 7
  • 40
  • 59
0

Looks like I found part of the answer: How to set different label for launcher rather than activity title?

When I added android:label="@string/app_name" to <intent-filter> open tag, I was able to put android:label="@string/main_activity_label" in <activity> open tag, and the app label was @string/app_name while the bar in MainActivity read @string/main_activity_label

Still no luck on the icon though...

Community
  • 1
  • 1
Novice coder
  • 163
  • 1
  • 8