开发者

Android -- How to disscociate the name of the application from the titlebar?

开发者 https://www.devze.com 2023-03-18 09:43 出处:网络
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 appl

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!


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).


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"


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消