当我尝试请求没有标题栏时,应用程序崩溃了
super.onCreate (savedInstanceState);this.requestWindowFeature (Window.FEATURE_NO_TITLE);this.getWindow () .setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);setContentView (R.layout.activity_main);
在style.xml中编写以下代码:
<style name="NoAB" parent="Theme.AppCompat.Light.NoActionBar"></style>
并将此主题应用于要隐藏操作栏的活动
<activity
android:name=".<YourActivity>"
android:theme="@style/NoAB" >
在super.onCreate(savedInstanceState)
之前调用this.requestWindowFeature(Window.FEATURE_NO_TITLE)