How do I remove the title bar in android studio?

2020-02-02 04:01发布

In my app there is this title bar at the top where the overflow menu would be, but I don't need settings and only have one screen. When I change the theme like described in many other questions I get the old 2.2 theme. I want to have the modern theme just without the bar at the top.

24条回答
Lonely孤独者°
2楼-- · 2020-02-02 04:47

Try changing styles to NoActionBar if that doesn't works add this code to your main activity

 protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
        setContentView(R.layout.activity_main);

    }
查看更多
女痞
3楼-- · 2020-02-02 04:48

Check this

 ActionBar actionBar = getSupportActionBar();
    actionBar.hide();
查看更多
贪生不怕死
4楼-- · 2020-02-02 04:50

delete the following from activity_main.xml

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"/>

contact me for more help

查看更多
成全新的幸福
5楼-- · 2020-02-02 04:50

Just use setTitle(null) above

toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

The title will disappear then you can use the logo of your choice.....

查看更多
地球回转人心会变
6楼-- · 2020-02-02 04:51

do this in you manifest file:

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
查看更多
手持菜刀,她持情操
7楼-- · 2020-02-02 04:52

Just call setTitle(null); in onCreate()

查看更多
登录 后发表回答