我想删除通知栏,但是应用程序一直被停止。我尝试了下面的代码,但它什么也没做。
<activity
android:name=".patient_pictureUpload"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>发布于 2021-06-10 06:11:39
在要使用的活动中,在Android4.0上使用,在AndroidManifest.xml ->中添加更低的,添加以下内容以隐藏状态栏:
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >是通过设置WindowManager标志:来编程实现的
编写辅助函数
void hideStatusBar() {
// For Android version lower than Jellybean, use this call to hide the status bar.
if (Build.VERSION.SDK_INT < 16) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}在onCreate()中使用助手函数
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideStatusBar();
// We should never show the action bar if the status bar is hidden, so hide that too
//if necessary.
getSupportActionBar().hide() // if you have extended the activity from support lib like Appcompat, else use getActionBar().hide() here
setContentView(R.layout.activity_main);
}请注意:
从这里找到更多详细信息
https://stackoverflow.com/questions/67914068
复制相似问题