I have tried to remove the title bar using the code below. But it doesnt work and it still shows the title bar.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
setContentView(R.layout.activity_main);
}
i even tried changing the theme in the mainfest file as follows.But the app stops working saying " Unfortunately myApp has stopped working".
<activity android:name="..."
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
Do this before calling setContentView()
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
if (getSupportActionBar() != null)
getSupportActionBar().hide();
//Remove notification bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Related
What Android theme should be used if I want full screen activities with white backgrounds running on devices supporting API 14+?
try this in your oncreate
public 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.main);
}
I am working on an android project. And I want to show / hide the custom title bar on Button click. This button is for media player (full screen size / custom screen size ) please help me.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main1);
ctx=this;
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title1);
// FrameLayout frameLayout = (FrameLayout) findViewById(R.id.menu);
// FrameLayout frameLayout2 = (FrameLayout) findViewById(R.id.menu1);
for hide custom title i am using using following code onClick()
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
This is will hide the action bar:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this will make him back:
this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
I am trying to make a fullscreen activity, but it doesn't seem to work in GingerBread, here is my code
#SuppressLint("NewApi")
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eyes);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
ActionBar actionBar = getActionBar();
actionBar.hide();
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
In Gingerbread there is still a title.
Does anyone know how to fix this?
First of all you should set the activity as full screen in the manifest.
In the desired activity, add this code
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
and your onCreate should be like this
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
ActionBar actionBar = getActionBar();
actionBar.hide();
}
This might solve the problem.
Remember that you must call requestWindowFeature before call setContentView
Try this to make a full screen activity by java:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
and in Manifest
android:theme="#android:style/Theme.Translucent.NoTitleBar"
requestWindowFeature has to be called before super.onCreate. Like so:
#SuppressLint("NewApi")
#Override
public void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eyes);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
ActionBar actionBar = getActionBar();
actionBar.hide();
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
// ...
If this doesn't work, move the getWindow().setFlags(...) call to the top as well.
Unless you have a reason to not setting it in your manifest, add this attribute to your tag in the Manifest:
<application
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
.....
>
And I believe you wouldn't need the if-conditions code in the onCreate().
isn't just android:theme ="#android:style/Theme.NoTitleBar.Fullscreen" both hides the titlebar and the notification area?
it equals to:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
I learn this from https://github.com/pocorall/scaloid-apidemos/blob/master/src/main/java/com/example/android/apis/graphics/CameraPreview.java
I set the following property in application tag of manifeast file. but it hides both titlebar(Actionbar) and Statusbar.Here i want to hide only the statusbar.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
for hiding only status bar add this code in oncrete of activity:
// Hide the Status Bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
and remove android:theme="#android:style/Theme.NoTitleBar.Fullscreen" from manifest
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
add this code to begining of your activity
Try the following code snippet:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* add below 2 lines*/
getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
I know that an app can be made full screen by tag in the manifest of the activity android:theme="#android:style/Theme.NoTitleBar.Fullscreen" Is it possible to switch to full screen mode from within the app, programmatically?
add two lines...
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
You can create new style and add
<item name="android:windowFullscreen">true</item>
Or you can do it programmatically:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
add this in Activity onCreate before setContentView:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
and in AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
If you need a fullscreen immersive mode (for games, galleries, etc.), here is the solution I use and recommend.
The most efficient way is to set the SystemUIVisibility only when is needed:
In your onCreate()
With OnSystemUIChangeListener when the fullscreen mode is lost
public class BaseActivity extends Activity {
#SuppressLint("InlinedApi")
private static final int UI_OPTIONS = View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Step 1
hideSystemUI();
// Step 2
getWindow().getDecorView()
.setOnSystemUiVisibilityChangeListener(new View
.OnSystemUiVisibilityChangeListener() {
#Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
hideSystemUI();
}
}
});
}
private void hideSystemUI() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) actionBar.hide();
getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS);
}
}
Try this,
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
or
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
in onCreate() method write
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);