How do you remove the title text from the Android

2019-01-10 02:55发布

I'm looking through the Holo.Light theme, and I can't seem to find the magic style to override to get rid of the title text that briefly shows up when my app first launches.

How can I do that?

20条回答
疯言疯语
2楼-- · 2019-01-10 03:34

Try:

getActionBar().setDisplayShowTitleEnabled(false);

For v.7:

getSupportActionBar().setDisplayShowTitleEnabled(false);

查看更多
\"骚年 ilove
3楼-- · 2019-01-10 03:35

I tried this. This will help -

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

getSupportActionBar should be called after setSupportActionBar, thus setting the toolbar, otherwise, NullpointerException because there is no toolbar set. Hope this helps

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-10 03:37

I am new to Android so maybe I am wrong...but to solve this problem cant we just go to the manifest and remove the activity label

<activity
        android:name=".Bcft"
        android:screenOrientation="portrait"

        **android:label="" >**

Worked for me....

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-10 03:38

i use this code in App manifest

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:logo="@drawable/logo2"
        android:label="@string/title_text"
        android:theme="@style/Theme.Zinoostyle" >

my logo file is 200*800 pixel and use this code in main activity.java

getActionBar().setDisplayShowTitleEnabled(false);

it will work Corectly

查看更多
beautiful°
6楼-- · 2019-01-10 03:42

If you only want to do it for one activity and perhaps even dynamically, you can also use

ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);
查看更多
对你真心纯属浪费
7楼-- · 2019-01-10 03:43

The only thing that really worked for me was to add:

<activity 
    android:name=".ActivityHere"
    android:label=""
>
查看更多
登录 后发表回答