How do I remove the title bar in android studio?

后端 未结 24 1185
轮回少年
轮回少年 2020-12-04 08:03

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

相关标签:
24条回答
  • 2020-12-04 08:38

    Best way is to use actionbar function setTitle() if you wish to show logo or have some other stuff in you actionBar but dont want to see name of the app, write this code in MainActivity.java or anywhere you wish to hide title in onCreate:

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(R.mipmap.full_white_logo_m); // display logo
    actionBar.setTitle(""); // hide title
    

    This way your app won't have reason to crash.

    0 讨论(0)
  • 2020-12-04 08:38

    Just call setTitle(null); in onCreate()

    0 讨论(0)
  • 2020-12-04 08:41

    In the manifest file Change:

        android:theme="@style/AppTheme" >
        android:theme="@style/Theme.AppCompat.NoActionBar"
    
    0 讨论(0)
  • 2020-12-04 08:41

    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);
    
        }
    
    0 讨论(0)
  • 2020-12-04 08:43

    This was working for me on values/styles.xml add items:

           `<item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>`
    
    0 讨论(0)
  • 2020-12-04 08:44

    Go to styles.xml and change .DarkActionBar for .NoActionBar

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
    </style>
    

    becomes

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
    </style>
    

    if colors are irrelevant to your app, you can actually go for

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />
    
    0 讨论(0)
提交回复
热议问题