How to remove the title when launching android app?

心不动则不痛 提交于 2019-12-09 04:50:19

问题


I already remove the title in onCreate() method.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
}

The title is not displayed. But still appears when launching the app.

And I can use

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

or put

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

into manifest file because I'm using actionBar. If I did that, the app crashes.

So, my question is, is there any way to remove the title when the app is launching because I am gonna put a splashscreen here. Thanks.

-----------

PLEASE NOTICE:

Thanks for your answers, but I clearly said that I already used actionBar.setDisplayShowTitleEnabled(false); to hide the title bar of the activity. (as shown in the first picture) BUT the title bar still appears in the launching screen (as shown in the second picture.)

and

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

and

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

would lead to crash launch. This happens after I used actionbar.


回答1:


I had the same problem.

Personally, I solved it by replacing my Activity inheritance from ActionBarActivity to Activity.

Hope this will help someone...




回答2:


Do this in your onCreate() method.

//Remove title bar

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

this refers to the Activity.

===========

EDIT:

if you are using ActionBarSherLock

final ActionBar bar = getSupportActionBar();
bar.setDisplayShowTitleEnabled(false);



回答3:


It might be crashing because you are using this.requestWindowFeature(Window.FEATURE_NO_TITLE); after setContentView();

Use this.requestWindowFeature(Window.FEATURE_NO_TITLE); in onCreate() of your Activity , before setContentView(); statement.




回答4:


May be i am repeating the same which all are saying but i just need to confirm it.In manifest file have add the theme like the below which i added as sample or anyother way.

<application .... android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:largeHeap="true"> .. </application>

Just remove all other code related to hide title bar only andonly add this one in the manifest file it works for me.I hope it will work to you too.




回答5:


Nick Butcher and Katherine Kuan wrote a nice Google Plus post about a smoother app launch experience:

https://plus.google.com/+AndroidDevelopers/posts/VVpjo7KDx4H

However, if you want to be compatible with Android versions below API 14 (for example using AppCompat), the only way I could achieve this is by using a separate launch activity using a theme with no actionbar.




回答6:


Set your splashscreen as your main activity and set the theme to

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

create and intent to move your splash screen to your actual main activity




回答7:


Use this:

 ActionBar bar = getActionBar();    
 bar.hide();

or

    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);



回答8:


in res/values/styles.xml

find ...

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
   <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

replacing for.

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="windowActionBar">false</item>
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

Save and compile...




回答9:


Put below three line in onCreate Method before setContentview in your activity which want to display full screen

requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);




回答10:


Hope below lines will help you

    getWindow().clearFlags(
            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);



回答11:


You can simply add full screen theme to that activity in your manifest file:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"



回答12:


In your AndroidManifest.xml in application tag set your theme to full screen like in below code.

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"


来源:https://stackoverflow.com/questions/17825524/how-to-remove-the-title-when-launching-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!