I wanted to show first screen (user's registration) without label and settings menu.
would someone please suggest me how?
Following is the code from manifest.xml
<activity
android:name=".LoginActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
The settings icon is the menu option in Android. To remove that just remove the onCreateOptionsMenu() method. But since you also want to remove the title, all in all what you are asking is to remove the action bar itself. That means you want a full screen activity and for that you can simply set a style in the android manifest.
<activity android:name=".LoginActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
I wish to use a logo on the actionbar without displaying the application or activity label:
In order to display the app name with the launcher icon and everywhere else the app appears I must use:
android:label="#string/app_name"
with the activity containing:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If I set the application label to android:label=""
and or use setTitle("");
after setting the launcher activity label to the app name, the app name is displayed over actionbar logo for a second before being removed.
My question is how can I keep my actionbar logo and app name under the launcher icon but never display the label.
I could use a splash screen and give that activity the
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
attributes but that is a workaround I do not wish to do.
Thanks in advance.
A quick and simple solution would be using an empty string resource as the label:
First Create an empty string resource and then replace
android:label="#string/app_name"
with
android:label="#string/your_empty_string"
Inside AndroidManifest.xml
So the actionbar logo would still display and the title would be empty, without that delay you mentioned in your post when changing the actionbar's title programically.
I have a little problem, my appliction always display my icon in the menu, home screen stc. My app is a wallpaper app, but in the wallpaper setting list always display a gray images without my icon. Where I can configure that?
In AndroidManifest.xml find application tag and add android:icon="#drawable/icon" replacing icon with id of your resource.
Something like this:
<activity
android:name="com.cotv.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/QTheme.PageIndicatorDefaults" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am finding that in my Android application, the name of the application is displaying on the top of every screen, consuming a line of valuable screen real estate.
I am using LinearLayouts
How can I get this not to display?
You can set it in the Activity/Application tags in the manifest XML:
android:theme="#android:style/Theme.NoTitleBar"
See more here (Styles and Themes).
Or write in onCreate yours Activity before setContentView():
requestWindowFeature(Window.FEATURE_NO_TITLE);
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<activity
android:name=".A"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
you can add this line android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" to the manifest and make your application fullscreen and without title bar
and if you want to remove only the title bar and don't want to make the application full screen then you can use Theme.NoTitleBar
Change your activities' theme like that
<activity android:name=".Activity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:theme="#style/AppTheme"
Above change in Manifest file didn't work for me.
requestWindowFeature(Window.FEATURE_NO_TITLE)
For this to work in your project you have to make one more change. Make your acivity extends Activity instead of AppCompactActivity which comes by default.
Thank You.
This question has been asked before - but with no satisfying answer at all! So I'm trying it again.
I want to give my application launcher icon (the one that is displayed on the startscreen!) a different, shorter caption. It seems the launcher takes its label from the mainfest section about the main activity's label, as here:
<activity android:name="MainActivity" android:label="#string/app_short_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I already changed the original reference to my app's name #string/app_name to a different, shorter string resource here.
BUT - big BUT: this also of course changes this activity's default title! And I did not want that to happen, there's enough space for a long application name! Setting the long title again in onCreate using the setTitle(int) method does no good either, because the short name will be visible to the user for a short time, but long enough to notice!
And - please don't answer my question by refering to a custom titlebar... I do not want to go that long way, just because of a stupid string title! It's a pain to draw a custom title bar for so little effect!
Is there no easy way to just give the launcher a different string to display?
Thanks for your answers!
Edit: One more reason why having a custom titlebar is a pain is that it will not look like the default titlebar, I would have to explicitly do things to make it look alike on each device! And that can't be a solution if, after all, I don't want a different appearance!
Apparently <intent-filter> can have a label attribute. If it's absent the label is inherited from the parent component (either Activity or Application). So using this, you can set a label for the launcher icon, while still having the Activity with its own title.
Note that, while this works on emulators, it might not work on real devices, because it depends on the launcher implementation that is used.
http://developer.android.com/guide/topics/manifest/intent-filter-element.html
<activity
android:name=".ui.HomeActivity"
android:label="#string/title_home_activity"
android:icon="#drawable/icon">
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Side Note: <intent-filter> can also have an icon attribute, but
inexplicably it does not override the icon specified in the
Activity. This may be important to you if you plan to use the native
ActionBar in SDK 11+, which uses Icon and Logo specified on the
Activity.
Added Info: The label is being inherited from Activity and not the Application.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".StartActivity"
android:label="#string/app_long_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In this case, app_long_name will be displayed with launcher icon, if we do not put label inside as mentioned above.
I was looking for the same thing and here's what worked for me.
<activity android:name="MainActivity" android:label="#string/app_short_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This will give a short name to your application launcher icon.
To add a larger name to the application bar you just have to add:
this.setTitle(getResources().getString(R.string.app_name));
to your main activity java file.
Solution of Mark Renouf fails to me (using Nexus 4 and Android 4.4). It fails when using shortcuts, shortcuts use the main activity label instead of the app name. I saw some apps like GMail and Google Keep that works fine. But when you open them, I notice its like a moment between the title is blank and the title appears (which seems better than the app name flashing before setting the title using setTitle()).
So here is the best solution I found:
Create a style where the ActionBar does not show the title/label:
<style name="NoActionBarTitle" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/NoActionBarTitle.ActionBar</item>
</style>
<style name="NoActionBarTitle.ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
I'm using a navigation drawer and using a logo (because I use a logo and an icon for my app). You can use whatever but don't use showTitle. Then in the AndroidManifest.xml, set the theme for the MainActivity:
<activity
android:name="com.xx.xxx.MainActivity"
android:logo="#drawable/ic_icon_padding"
android:theme="#style/NoActionBarTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Then, in the onCreate() method of the MainActivity, set the title of your Action Bar:
getActionBar().setTitle(R.string.your_title);
After it, you can call:
getActionBar().setDisplayShowTitleEnabled(true);
Tricky but worth.
This probably won't satisfy what you want to do, but have you thought about creating a splash screen that displays very briefly (with the default title) and then launches your new actual "main" activity with the title of your choosing using the setTitle(int) method? I have not tried this to see if it works but that might create a pleasant work around that does not show of the less than seamless nature of what you are trying to achieve.
For anyone using Support / Appcompat Toolbar via the setSupportActionBar() method, the Activity title can be set in Toolbar XML:
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
app:title="#string/activity_title"
...
/>
This will override application and activity labels set in the manifest.
android.support.v7.widget.Toolbar
I found a workaround for this problem
In manifest.xml
Write your app's name in the android:label of the launcher(main) activity.
This will make the label of your main activity same as that of the app label.
Then, in the onCreate() function of your Launcher(main) activity write this statement
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("main activity label");
}
Here write the label that you want to give to your Launcher(main) activity.
You can do something like this:
public class FooBar extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// change title
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title);
}
}
You'll have to create a custom layout to hold the title. It could be as simple as (called my_title.xml in this case):
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="foo bar"/>
In your AndroidManifest.xml file you just have to set the title for the app, which is what is going to be shown in the launcher icon. For your activity you don't need to set a title there.
The launcher actually shows android:label and android:icon for activity(ies) that declare
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
so application label is of no use.