Remove title in Toolbar in appcompat-v7

前端 未结 18 1411
孤街浪徒
孤街浪徒 2020-12-07 09:52

The documentation of Toolbar says

If an app uses a logo image it should strongly consider omitting a title and subtitle.

相关标签:
18条回答
  • 2020-12-07 10:40

    Just add this attribute to your toolbar

    app:title=" "
    
    0 讨论(0)
  • 2020-12-07 10:44

    Nobody mentioned:

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
            super.onCreate(savedInstanceState);
        }
    
    0 讨论(0)
  • 2020-12-07 10:45
     Toolbar actionBar = (Toolbar)findViewById(R.id.toolbar);
        actionBar.addView(view);
        setSupportActionBar(actionBar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    

    take note of this line getSupportActionBar().setDisplayShowTitleEnabled(false);

    0 讨论(0)
  • 2020-12-07 10:48

    The reason for my answer on this is because the most upvoted answer itself failed to solve my problem. I have figured out this problem by doing this.

    <activity android:name="NAME OF YOUR ACTIVITY"
        android:label="" />
    

    Hope this will help others too.

    0 讨论(0)
  • 2020-12-07 10:49
    Toolbar toolbar = findViewById(R.id.myToolbar);
        toolbar.setTitle("");
    
    0 讨论(0)
  • 2020-12-07 10:51

    If you are using Toolbar try below code:

    toolbar.setTitle("");
    
    0 讨论(0)
提交回复
热议问题