Define different title in menu bar and Homescreen for Activity - android

In my Android app I'm setting the title for an Activity using android:label in the AndroidManifest.xml. But now I want to display different titles in the Menu Bar (when the app is opened) and for the caption under my icon on the Homescreen. Is there any way to achieve this using xml? Or do I have to set the title for the Startscreen icon in the xml and have to set the title displayed in the ActionBar using Activity.setTitle() ?

The text under the icon on home screen is defined by android:label in <application> element in your manifest xml.
The same android:label exists for each activity in <activity> element. This will set the text in the action bar/title bar for each activity separately.
<application
android:label="#string/home_screen_app_name"
<activity
android:name=".main"
android:label="#string/main_activity_title">
</activity>
</application>

I found a question that does answer mine: How to set different label for launcher rather than activity title? Short, the answer is to set the label attribute in the intent

Related

Setting a button in a Title Bar of an Android app

I know that it is possible to add a Back Button to a Title Bar in an Android app, by setting:
<activity
android:name=".MyActivity"
...
android:parentActivityName=".SomeActivity"
... />
in AndroidManifest.xml.
Is it also possible to add an arbitrary button with some functionality in the Title Bar?
If YES, what is the way to do it?

Navigation drawer change to rtl programmatically

I want to change language and layout/text orientation in my app programmatically.
But navigation drawer doesn't change it's items.
Is it possible?
1)First You have to define android:supportsRtl="true" this line in your application tag in manifest.
and check this link - https://www.androidhive.info/2014/07/android-building-multi-language-supported-app/

Custom Title Bar in android studio for my contact app I have designed how id like it to look in photoshop

Hey all I'd like help in creating my app in android studio I am new to this so I'll do my best to try and help you all understand best into what I am trying to do.
I am going to post two pics of how my design should look and I can't seem to get the start of the title bar done. In android studio it always on all of the project start-ups puts a black title bar with a picture of an android and its all black id like it to be cleared of the photo and re colour'd into red and the title text center'd as in my design image.
any help would be much appreciated
this should show the two pictures of my design
While you can edit the xml to change the ActionBar, your best bet is going to be using the new Toolbar. A toolbar is a fully customizable ActionBar without a lot of the traditional constraints of it. You can treat the toolbar just like any other layout container and include layout elements inside like TextViews, etc.
After you have designed your toolbar in xml, you can simply set the toolbar to be your action bar by calling activity.setSupportActionBar(yourToolbar);
This is much more flexible and allows much more control over the look and feel than using the traditional action bar.
Action bar custom label
AndroidManifest.xml:
<activity
android:name="com.package.app.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You can change the android:label from your app name to your desired title for each activity you have.
Action bar background color
To change the action bar background, create a custom theme for your activity that overrides the actionBarStyle property. This property points to another style in which you can override the background property to specify a drawable resource for the action bar background.
Styling the Action Bar

Android - How to avoid delay when calling setTitle() in activity's onCreate()

The title of my SplashActivity is quite long, so appears truncated beneath the launch icon on the device's home screen.
I want a shorter title shown beneath the launch icon, but a longer title shown in the Activity's action bar.
So, to try and achieve this I have specified a shorter title in the manifest...
<activity
android:name=".SplashActivity"
android:label="#string/app_name_short"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...and I'm using...
setTitle(getString(R.string.app_name));
...in the onCreate() method of SplashActivity so that the full title appears in the action bar.
It works, but only after about a 1 second delay. (So when SplashActivity is displayed, it shows the short title for 1 second before changing to the longer title.)
Is there any way I can fix this or any known workaround?
I've also tried creating a PreSplashActivity (with a short title) as the launch activity, including code to immediately launch SplashActivity (with a long title), but PreSplashActivity is still displayed for 1 second (even though it doesn't call setContentView(), so I'm a bit stumped.
Any ideas?
In this post answered by mark Renouf made it know that intent-filters can have a label attribute If it's absent the label is inherited from the parent component
Have you looked at the new docs for API21, specifically Toolbar? http://developer.android.com/reference/android/widget/Toolbar.html
With the new Toolbar you include it in your layout file like any other view. A nice side effect of this is that the initial screen is blank and the action bar appears in sync with the rest of your content. This gives you the option to set the title and make any customizations necessary before it becomes visible.
Here's details about using AppCompat to support older versions, it includes a section on using Toolbar in your layout and setting it as the action bar: http://android-developers.blogspot.ie/2014/10/appcompat-v21-material-design-for-pre.html

Different Launcher Name and Title Name

A similar question has been posted before but no satisfying answers yet.. The question is simple. I am using a custom Title Bar in my application (in the form on an image having text). However, When I use a title for the Launcher (the text beneath the launcher icon), it automatically sets the text for activity title and displays it under my customized title bar. If I use setTitle(""); at the start of the application to remove the title text, even then it shows it for a second ; enough to be noticed and if I completely remove the title bar text then it also removes the launcher title as well.. The application_label in Manifest file has nothing to do with the launcher title. The launcher title is obtained from Activity title which is quite annoying for me..
Any useful suggestions??
I understand you have two title bars? One 'from Android' and the other is your custom bar?
You can hide the Android-bar by using android:theme="#android:style/Theme.NoTitleBar" in the relevant activity in the manifest.
Did you use setTitle("") BEFORE calling setContentView(R.layout.your_activity) ? If so, it shouldn't show the text defined in your manifest at all because the setTitle() method call should have finished before the view is displayed. I use the same method to change the Title Bar text (and still maintain the Launcher text as defined in the manifest).
I will agree that it's strange the Launcher text isn't based on the android:label tag of <application>. The workaround of calling setTitle() in onCreate (before setContentView()) should do the trick though.

Categories

Resources