I have tried several things in order to hide the status bar in my app. It seems to work, but several users complain they still see the status bar. So, it looks like all proper solutions I have used, do not cover all devices/settings.
Here are the things I already added to my project:
In the AndroidManifest:
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
In the onCreate() method:
requestWindowFeature( Window.FEATURE_NO_TITLE );
getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
getWindow().getDecorView().requestLayout();
Now, this does work for almost all of my users. But some of them still see the status bar, even Galaxy S2 and S3 users (NOT ALL!).
Are there any other options left that I could try?
Try using only the Java code in onCreate() without the android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen".
Put the Java code to the beginning of your onCreate():
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Related
I just worked through the first introductory application for Android programming and noticed some strange behavior:
When the second Activity was generated it received the line:
getActionBar().setDisplayHomeAsUpEnabled(true);
in the onCreate function. As the tutorial points out, this line requires at least API level 11 and a guard for that and #SuppressLint("NewApi") should be added like so:
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
The strange thing is that ignoring this advice and just hitting run worked fine at first but as soon as I made changes to the code it didn't work anymore and I got errors.
So when is lint actually active?
I've gone through several posts in stackoverflow but i'm still unable to get the answer to a simple question:
Is it possible to create a fullscreen app in Android 3.x onwards, with the actionbar?
Using the #android:style/Theme.Holo.Light.DarkActionBar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
did not do the trick.
Using fullscreen theme, adding the actionbar through code did not do it either.
Does android not allow both to happen at the same time?
This works for me on all android versions ( from 4.0 up to 4.2 tested).
I do use actionbarsherlock, but that uses the native implementation on 4.0+.
#Override
protected void onResume() {
super.onResume();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}, 1000);
}
What also seems to work is adding it in XML! So that's even better, because it doesn't incurr a show and hiding of the notificationarea. Haven't seen this code anywhere.
<style name="Theme.MyTheme" parent="#style/Theme.PICK_A_PARENT_THEME_LIKE_ACTIONBAR">
<item name="android:windowFullscreen">true</item>
</style>
Tested the XML with actionbarsherlock and a freshly created non-actionbarsherlock project.
Both work ok (on 4.0.3). Below is the fresh non-abs app.
Yes nearly.
What worked for me is:
In the Activity in the onCreate method before set Content View:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_ACTION_BAR);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
and this is in the fragment part, but should also work in an activity:
getActivity().getActionBar().hide();
getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
Some devices only dim the navigation buttons. The space of the navigation buttons con not be used, but there are a lot of other View Constants you can use.
kind regards
I am using API 10 GingerBread
I am not using a layout, although I did try this with a layout and it still doesn't work. Works fine with a normal Activity subclass, I don't see what the problem is.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.ic_launcher);
For what it is worth, using FEATURE_NO_TITLE works fine. What gives? Anybody have any suggestions?
Try this code...
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.main); //or whatever layout is shows
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.ic_launcher);
I found bunch of samples how to remove title/notification bar on Android. However, it's still not a full screen.
I still see a panel on my table with search, home, back and some other button.
Do you have any ideas how to hide this panel?
Generally speaking, I want kind of kiosk mode.
Use this code in onCreate of activity:
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
Sample code for a fullscreen activity:
public class HellofullActivity extends Activity {
/** Called when the activity is first created. */
#Override
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);
}
}
where you request that the window has not the green title bar and take full screen.
The core problem was device specific. I was doing development for Archos and Archos has it's own bar, which isn't not removed by FLAG_FULLSCREEN and FEATURE_NO_TITLE
Any one can share the mainfest.xml.
How to set it? then can remove the label..?
Thanks very much
Your question isn't very clear, but assuming you're asking about displaying the name of your application: There's a line in the < application > section that has "#string/app_name" in it, which you could remove. Not sure that's a good idea though. Alternatively you might be asking how to remove the title bar at the top of an application. If so, use
requestWindowFeature(Window.FEATURE_NO_TITLE);
If by removing the default label, you mean removing the title bar, you can use the following in your onCreate
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}