2

I added a custom title-bar to an android application and this titlebar (which is a plain png) shows up inside the main activity. The problem is that the main activity also defines the name of the application using the label tag like this:

<activity android:name=".MainActivity" 
                  android:theme="@style/customTheme"
                  android:screenOrientation="portrait"
                  android:label="@string/app_name">
              <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
              </intent-filter>
 </activity>

And this label is also reported on the titlebar! How to dissociate the two? (Like basically, still be able to give a name to the application without affecting my custom title-bar).

Thanks!

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
  • Your answer has been already posted [here][1] [1]: http://stackoverflow.com/questions/3488664/android-launcher-label-vs-activity-title – jmhostalet Feb 18 '13 at 21:26

3 Answers3

4

You can change the header of any activity by using setTitle("THE TITLE"); in the java code for the page. If you want to use a string defined in the XML FILES, you can use setTitle(R.string.stringName).

jpevarnek
  • 381
  • 1
  • 8
  • This works but when the application starts the text remains for a moment before it disapears. I have read somewhere that this is some sort of optimization that android does but I can't find the link anymore and don't know how to fix this. Any idea? – Amokrane Chentir Jul 05 '11 at 09:34
  • 1
    You can set the text for the launcher icon separately by changing `` to `` in the AndroidManifest xml file. – jpevarnek Jul 05 '11 at 17:26
  • (I just re-read the question, I think what you are looking for is the answer kameny posted below, though I am not sure on that.) – jpevarnek Jul 05 '11 at 17:28
  • Kameny's idea is to remove totally the titlebar :). I want to remove the text. Your solution is the closest. Until now, I managed to solve this problem by adding a splahscreen which doesn't need a titlebar. – Amokrane Chentir Jul 05 '11 at 17:50
1

My opinion is to create your own custom title bar in the top of the screen and set the no title bar option in the manifest for the activity.

android:theme="@android:style/Theme.NoTitleBar"
kameny
  • 2,372
  • 4
  • 30
  • 40
0

try changing the label of your mainactivity to something like this android:label="@string/main_header" and define the string header in the strings.xml...

hope this good help you...

Dinash
  • 3,027
  • 4
  • 32
  • 45