Android hides the title status bar method

  • 2020-12-20 03:45:51
  • OfStack

This article shares two approaches, but I recommend using the first:

Using the first method, you just need to do a one-line configuration in the Manifest.xml file

And Activity won't see that Title column when it's launched

The first method:

Set in the configuration file:


<activity
android:label="@string/app_name"
android:name=".WelcomeActivity" 
android:theme="@android:style/Theme.NoTitleBar">
< In this way, setting the full screen can eliminate the entry Activity ", the one I saw title>

<activity
android:label="@string/app_name"
android:name=".WelcomeActivity" 
android:theme="@android:style/Theme.NoTitleBar.FullScreen">

// The above is only for setting without Title title. To make the full screen so necessary, set as:

The second method:


package com.example.hideproject;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.support.v4.app.NavUtils;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide title bar 
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Hidden status bar 
// Define full screen parameters 
int flag=WindowManager.LayoutParams.FLAG_FULLSCREEN;
// Gets the current form object 
Window window=MainActivity.this.getWindow();
// Sets the current form to display in full screen 
window.setFlags(flag, flag);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}

The above is the main implementation code: note that when setting the heading and setting the full-screen parameters 1 must be in setContentView(R.layout.activity_ES27en); Before otherwise the runtime will report an error!


Related articles: