Why Fullscreen mode is working just in Samsung phone? - android

There are some questions about Fullscreen but in my case, I'm using one java class with (AbsRuntimePermission extends AppCompatActivity) and the (MainActivity extends AbsRuntimePermission)
My problem is: the Fullscreen mode is working just in the Samsung phone.
By the way, the Home button is my problem, the title is already hidden.
In my MainActivity I'm using this windows code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestAppPermissions(new String[]{android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.INTERNET, Manifest.permission.READ_EXTERNAL_STORAGE}, R.string.msg, REQUEST_PERMISSION);
In my Styles I'm using the .AppCompat.NoActionBar.
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
Following another questions about Fullscreen, I tryed to use this code in my styles
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
and then change the manifest for theme .AppCompat.Light.NoActionBar.FullScreen But it is not working.
Are there any permission that I need to use when I have RuntimePermission?

solved: i have check this code it works on android version 4.0.4 api(15) and some above versions
after content view ADD this this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
chnage your style into
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
if your using api level 19 or above than use Immersive Full-Screen Mode override this function it will works fine
ex:
#Override
public void onWindowFocusChanged(boolean hasFocus){
super.onWindowFocusChanged(hasFocus);
View decorView = getWindow().getDecorView();
if(hasFocus){
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
}
hope answered the question if its useful than vote up

Related

How to hide title app when display a layout?

I have a layout A. When i enter to layout A, i want title app or actionbar will be hide.
i have searched in Google.
<style name="AppTheme.Fullscreen">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
But it must do in AndroidManifest.xml
(My app have many screen, and just only layout A, action bar will hide.)
So, i find a way which can set up it into file layout A?
How can i do that ?
use getSupportActionBar().hide(); to hide your action bar programtically
getSupportActionBar().hide();
if you want fullscreen activity than use below code
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.activity_main);
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".YourActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>

Xamarin.Forms .193 - AppCompat - Full screen - no action bar

Getting a full screen (no title bar/statusbar/navbar) when your MainActivity is inheriting from FormsApplicationActivity isn't much of a problem.
But then you can't theme it etc.
The current VS solution templates have you inheriting from FormsAppCompatActivity which you can theme. But then the status bar comes back.
It just shouldn't be days of looking at out-of-date how-to pages and mountains of trial and error with countless permutations of these different 'tricks' just to get a full-page app. I have hit every google search, every stack overflow, other questions here with examples that once worked in 2011 and so on. But I can't find or figure out how to make it work today, 2017 on a modern VS solution.
Maybe I've just tried so many different ways I've gotten lost or have multiple different ways conflicting with each other, but can anyone show me how on a basic "Welcome To Xamarin" kind of app how to get it go full screen? I've gotten so close, but not quite there. The best I can do is to have no content in the status bar, but the bar itself is still there. I can' t believe something as common place as wanting a full-screen app is kicking my arse, but it is.
Get rid of the Navigation bar
public partial class App : Application
{
public App()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
MainPage = new NavigationPage(new RpxOne.MainPage());
}
MainActivity.cs
Set the theme in the Activity attributes
Set the windows flags
(Clearly lot of various efforts and permutations to get this to work)
[Activity(Label = "RpxOne",
Icon = "#drawable/icon",
Theme = "#style/FullScreen",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize |
ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
WindowManagerFlags _originalFlags;
protected override void OnCreate(Bundle bundle)
{
SupportRequestWindowFeature((int)WindowFeatures.NoTitle);
//RequestWindowFeature(WindowFeatures.NoTitle);
//TabLayoutResource = Resource.Layout.Tabbar;
//ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
//if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
//{
// // Kill status bar underlay added by FormsAppCompatActivity
// // Must be done before calling FormsAppCompatActivity.OnCreate
// this.Window.DecorView.SystemUiVisibility = StatusBarVisibility.Hidden;
// ActionBar?.Hide();
//}
//else
//{
// this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
// SupportActionBar?.Hide();
//}
//global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);
//Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);
//Window.ClearFlags(WindowManagerFlags.Fullscreen);
//Window.AddFlags(WindowManagerFlags.Fullscreen |
// WindowManagerFlags.TurnScreenOn |
// WindowManagerFlags.KeepScreenOn);
this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
this.Window.AddFlags(WindowManagerFlags.Fullscreen); // hide the status bar
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
And then the theme itself
<style name="FullScreen" parent="#style/Theme.AppCompat.Light.NoActionBar">
<!--<item name="windowNoTitle">true</item>-->
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<!--<item name="android:windowContentOverlay">#null</item>
<item name="android:actionBarSize">0dp</item>-->
<!--<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
--><!-- No backgrounds, titles or window float --><!--
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">false</item>
--><!--<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>-->
</style>
Original post on Xamarin Forums
https://forums.xamarin.com/discussion/90145/how-to-get-a-full-screen-app-in-todays-xf-193-appcompat-environment-it-shouldnt-be-this-hard
No replies - I can't believe this is such a mystery.
Code for hiding title bar and action bar actually works, the action bar you see is a view created by Xamarin.Forms view renderer. By checking the Hierarchy Viewer of DDMS, you can see this view:
Since we cannot modify the source code of xamarin forms, here is a workaround to solve this issue. Create a style like so:
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<!--colorPrimaryDark is used for the status bar-->
<item name="colorPrimaryDark">#fff9f9f9</item>
</style>
And in MainActivity:
[Activity(Label = "FormsIssue6", Icon = "#drawable/icon", Theme = "#style/Theme.AppCompat.Light.NoActionBar.FullScreen", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
//ToolbarResource = Resource.Layout.Toolbar;
//RequestWindowFeature(WindowFeatures.NoTitle);
//Window.AddFlags(WindowManagerFlags.Fullscreen | WindowManagerFlags.TurnScreenOn);
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
This is only a workaround, the view there for action bar will still occupy the space in the layout.
And the reason why I used color #fff9f9f9, I only check the souce code, the <drawable name="input_method_fullscreen_background"> item seems to be right by my side, I didn't find the source code for Xamarin.Forms, you can give a try.

How can i remove icon and title from ActionBar in Android on startup?

In my android project, I wish to disable icon and the title in ActionBar.
Here is the code:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowHomeEnabled(false);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
But always on startup they appear and after a while they disappear but i don't want them at all. How can i remove them on startup?
call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.
actionBar.setDisplayUseLogoEnabled(false); should do it.
Or
For Splashscreen you should use this line in manifest and don't use getActionBar()
<item name="android:windowActionBar">false</item>
and once when Splash Activity is finished in the main Activity use below or nothing
<item name="android:windowActionBar">true</item>
Reffer this ----> click here
You can use below code for that -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar" />
If you want the full screen of your device you can use below code -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
And, also refer Developer's Site
Another method
Do this in your onCreate() method.
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
this refers to the Activity.
Maybe this answer can help you. It helped me.
<quote>
Best method is to set the display options to useLogo in your theme. E.g.
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">useLogo</item>
</style>
This won't actually show the logo (if set) because showHome is not included.
</quote>
try this:
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
setContentView(R.layout.activity_main);
}
NOTE: The getActionBar() method was added in Honeycomb (API: 11) and later

notification bar in libgdx game

I want to create game using Libgdx engine. It's create by default FULLSCREEN game without notification bar.
Can i create game with notification bar?
Since I am not (yet) allowed to comment I will make it an answer. Basically everything said by LiamJPeters helps, except you have set up the project recently from scratch with one of the newer libgdx nightlies, then there will also be a "res/values/styles.xml" which is referenced in the manifest.
I had to change two settings there (in addition to everything written by LiamJPeters) to make it finally show the notification bar and the window title:
<resources>
<style name="GdxTheme" parent="android:Theme">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources>
In the Android starter:
public class MainActivity extends AndroidApplication {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.hideStatusBar = false;
initialize(new MainClass(), cfg);
}
}
The important line here being cfg.hideStatusBar = false;
Hope that helps
EDIT
Ok so I've done a bit of research on the subject and it turns out it's pretty easy. I looked on the libgdx wiki page for adding admob ads. Follow all the steps except adding the ads!
Below is modified code for setting up a non-fullscreen android app:
public class MainActivity extends AndroidApplication {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout layout = new RelativeLayout(this);
layout.addView(initializeForView(new MainClass(), false));
setContentView(layout);
}
}
You can add all the layout parameters you want very easily by googleing "RelativeLayout layoutParams". Hope this helps. Please mark the question as answered.
I run into a confusion here and couldn't make it work for a while on Android Lollipop. I had to actually merge all the code provided here in the answers, to make my app show status bar.
So the final working code for me looks like this:
Java part - combining relative layout and hideStatusBar config (thanks to LiamJPeters)
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.hideStatusBar = false;
RelativeLayout layout = new RelativeLayout(this);
layout.addView(initializeForView(new MyAndroidApp(), config));
setContentView(layout);
}
And styles.xml part - windowFullscreen to false (thanks to Bernrd K.)
<resources>
<style name="GdxTheme" parent="android:Theme">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources>
Note: windowNoTitle has nothing to do with status bar itself. Depends what you need, but the xml above shows the status bar only, no titles.

Hide Notification bar

Anyone know how to disable/hide notification bar at the top which show battery and other things in android.
Any help will be appreciated.
EDIT: Please also add how can I hide ActionBar+NotificationBar for later android versions.
You could use a theme in your AndroidManifest.xml:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
or change parent of your AppTheme to #android:style/Theme.NoTitleBar.Fullscreen like this
<style name="AppTheme" parent="Theme.NoTitleBar.Fullscreen">
</style>
then apply this theme on activities which you want Fullscreen like
android:theme="#style/AppTheme"
or use the following code snippet:
public class FullScreen
extends android.app.Activity
{
#Override
public void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
The answers above hide ActionBar too.
If you intend to only hide notification bar, use this code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
be careful to put it before setContentView().
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Another Simple option is to add <item name="android:windowFullscreen">true</item> on the theme you will apply to activities that don't need a notification bar...
like so..
<style name="AppTheme.Splash">
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
Works like charm
Successfully implemented a slightly modified version of #Martin's suggestion along with a custom theme to get rid of BOTH the Status and Navigation Bar.
public class MyActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//* Hides Notification Bar
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_my);
}
Top part is used to get rid of the Status bar. Add the following code to your #styles as a resource to kill off the NavBar as well.
<resources> <style name="NoNav" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style> </resources>
After you add this to your resource file, pop open AndroidManifest.xml and chance your application theme to "#style/NoNav".
Android UI bloatware eliminated :)
You can use this for 4.1 or upper versions.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
you can do like this in onCreate() method :
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
actionBar.hide();
This answer is for android developers who like minimalist and simplified one-liner code. If you intend to only hide notification bar, use this code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
be careful to put it before setContentView() in your on create() function of required activity.class

Categories

Resources