How do I remove the title bar in android studio?

后端 未结 24 1174
轮回少年
轮回少年 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:33

    In styles.xml file, change DarkActionBar to NoActionBar

        <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>
    

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

    In the manifest file change to this:

    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    
    0 讨论(0)
  • Go to Project -> app -> main -> res -> values -> styles.xml

    Change this line if you want to delete it for every view

     `<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">`
    

    to

     `<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">`
    

    if you want to make it just for one view you can change it in youre manifest data. Go to Android -> manifests -> AndroidManifest.xml. do following:

    1. Search the View you want to get this type of change <activity android:name"...">
    2. Add android:theme=""@style/Theme.AppCompat.NoActionBar"
    0 讨论(0)
  • 2020-12-04 08:36

    This works for me

    getSupportActionBar().hide();
    
    0 讨论(0)
  • 2020-12-04 08:37

    This works for me i hope this work for you as well

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
    }
    
    0 讨论(0)
  • 2020-12-04 08:37

    I have faced the same problem as you, and solve this problem just by changing the class which I extended.

    //you will get the app that does not have a title bar at the top.
    import android.app.Activity;
    public class MainActivity extends Activity
    {}
    
    //you will get the app that has title bar at top
    import androidx.appcompat.app.AppCompatActivity;
    public class MainActivity extends AppCompatActivity
    {}
    

    I hope this will solve your problem.

    0 讨论(0)
提交回复
热议问题