Android full screen theme for ICS and above - android

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);
}

Related

How to remove title bar and operate in full screen mode?

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);

How to HIDE/SHOW CUSTOM Title On button click In Android

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);

Android Fullscreen Not Working: Gingerbread

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

How can I add an image to the title bar in android 3.0?

I am learning android 3.0.
Can any one tell How can add Image in Title bar in android 3.0?
In developer site they are telling by default it will come.but for me it is not coming.
Thanks in advance.
You will have to create Custom Title Bar Layout to add your own image in titlebar.And then you can use following code to assign the titlebar to your view
boolean customTitleSupported;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if (customTitleSupported) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_tittlebar_layout);
}
setContentView(R.layout.main);
}
here custom_tittlebar_layout refers to your custom titlebar layout with image.

How to apply Theme.Wallpaper at runtime on android?

I use following code :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Wallpaper);
setContentView(R.layout.main);
}
But it does nothing!
How can I apply Theme.Wallpaper at runtime on android?
It works when you call the setTheme() method even before the call to the constructor of your parent class (i.e. before super.onCreate(...)).
The following works for me:
public void onCreate(Bundle savedInstanceState) {
setTheme(android.R.style.Theme_Wallpaper);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
However, it's not perfect: when launching the activity, the shown animation still belongs to the default theme -> a black screen fades in. After the animation finishes, the wallpaper theme is shown.
If you want to have a wallpaper-themed fade-in animation, you have to use the declaration in your AndroidManifest.xml

Categories

Resources