如何隐藏android的屏幕上的Title Bar

艾晓雪

关注

阅读 65

2023-03-21


1. 在Activity中的onCreate方法中加入如下代码:

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);


2.修改AndroidManifest.xml中的activity节点的theme属性


<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">


3.修改AndroidManifest.xml中的application节点的theme属性


精彩评论(0)

0 0 举报