Latest Samsung's smartphone has interesting feature called full screen (or in marketing terms infinity display). In this mode app covers also part of display where home/back buttons are. Usual apps don't cover this area, leaving it black. But Samsung's native ones cover this area.
Question: how to achieve this effect? I mean what kind of manifest declaration or programmatic call (possibly Samsung's legacy API) should I use?
To enable new Samsung Galaxy S8 and LG G6 full screen support add to the AndroidManifest.xml under the <application> element:
<meta-data android:name="android.max_aspect" android:value="2.1" />
Where value of 2.1 is aspect ratio 18.5:9 (By default your App defaults to maximum ratio for 16:9 - 1.86). More info in: Android Blog.
Alternatively, you can set the following attribute for Application or Activity:
android:resizeableActivity="true"
Because the documentations states (link):
You do not need to set a maximum aspect ratio if an activity's
android:resizeableActivity attribute is set to true. If your app
targets API level 24 or higher, this attribute defaults to true.
to get full-screen you must overide onWindowFocusChanged method and create decorView object and add System_UI flags into it..
#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 // this flag do=Semi-transparent bars temporarily appear and then hide again
|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // Make Content Appear Behind the status Bar
|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // it Make Content Appear Behind the Navigation Bar
|View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
}
It can be turned off. I used this tutorial for my S8
How To Enable Full Screen Apps on Galaxy S8/S8+
Related
I had locked my app to portrait only mode and I handled orientation changes myself, but I realized that in landscape mode the status bar stays the same, and the UI experience would be bad.
Now, that I have developed everything accordingly, the only workaround seems to be for me is to change the status bar position programmatically, since I don't(or actually can't at this point) respect system orientation changes.
Is this possible? To change the status bar position programmatically? Only inside my app and restore once I exit?
Below I have illustrated the desired effect:
first, the app is locked to portrait mode and when I rotate the device the app's views rotate since I parse the raw sensor data and apply the rotation, but in this case the status bar doesn't rotate(since the app is locked to portrait mode, and I only have access to app's views for rotation):
A pseudocode of how I've done the above is:
View views[] = new View[]{view1, view2, view3, view4 ....};
float rotationAngle = parseRawSensorData();//typically accelerometer input
for(View view: views){
rotateWithAngle(rotationAngle);
}
Therefore the views rotate but the status bar is affixed.
what I'd like to do is to be able to rotate the status bar using some code like this:
i.e. rotate the statusbar according to the sensordata I fetch.
The statusbar is part of the Android system, not part of your application. So there is no way you could control that from your application.
Instead of rotating a status bar, you can just hide it when using your app.
Import:
import android.view.WindowManager
And write this:
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
I'm working on a German Learning app project, inspired by Duolingo app.
I need to make my app to be a little bit similar with this feature. It's like making the user to focus on the quiz, and ignore everything in status bar (notification bar). Now, what I need is i want to hide the icons on notification bar. Is there a way to do so?
This is what I want
And this is the fact
You can dim the status and navigation bars by setting the SYSTEM_UI_FLAG_LOW_PROFILE flag.
View decorView = getActivity().getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
https://developer.android.com/training/system-ui/dim.html
This decoration is reset whenever the keyboard is made visible, but you can watch for the keyboard being hidden (using an onGlobalLayoutListener) and resetting the flag.
You could just disable notifications for the offending apps in your device's settings menu. I'm looking for an option to hide them from the status bar while keeping notifications in the shade and on the lock screen. Apparently not on a Samsung device.
I'm interested in an app that customizes the Android NavigationBar across all my applications. The same way that, i.e. NavBar Apps does it.
This far, I found two possibilities, but it doesn't fit exactly what I'm looking for:
SystemBarTint library (here)
It only works if you set your app to translucent, and display a background "tint" behind the NavigationBar.
setNavigationBarColor(int color) (here)
You can only use a color (and not a drawable) for the NavigationBar.
I want do an app that is always running and can set a drawable instead of the black color of the NavigationBar
I found out a way to customize the NavigationBar in (almost) all apps. (following this)
Using this permission:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Then I created a Service that calls:
WindowManager.addView(View v, LayoutParams p)
And my MainActivity starts this Service.
You cannot change the status/navigation bars color on all apps unless you are a rooted user and your custom rom / custom launcher supports this.
You can only change this inside you own application with any of the links you provided. But this will not extend to the rest of the device apps.
If the case is inside your own app you can do this by using setNavigationBarColor for the nacigation bar and the material design library for the status bar (set the secondaryColor on the material design.
In the 'new' Android Version 4.3 there is a new feature. The status Bar on the top of the screen is transparent in the launcher (I'm using Samsung TouchWiz on Galaxy S3) and in some other Apps too I think (looks a little bit like the iOS 7 style).
Can you tell me how I can make the Status Bar transparent (or colored) in my own App (Eclipse, Java)?
Theme.Holo.NoActionBar.TranslucentDecor
Theme.Holo.Light.NoActionBar.TranslucentDecor
Based on the best answer here: How to make the navigation bar transparent
I'm not sure about the transparency but as of API 10 you can set a background drawable for the actionBar. (and thus a color)
In the following codesnippet I get a color based on an attribute (depending on the theme chosen)
TypedArray a = getTheme().obtainStyledAttributes(new int[]{R.attr.background_activity_color});
actionBar.setBackgroundDrawable(a.getDrawable(0));
I was viewing a different question Google Maps Android API v2 - Interactive InfoWindow (like in original android google maps) and as you can see he's using the requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); to make the map v2 use the full screen. I tried this but the my location button is partially covered by the action bar on mine unlike his. Does anyone know how to move it down slightly?
Thanks!
Unfortunately you don't have any control over this button. Obviously, you can search for this button id in android sources and change layout params manually from the code, but I definitely wouldn't do that.
This button is super easy to implement yourself. So I recommend to disable built-in "locate me" button and implement your own which will be positioned right below the action bar.
To disable it use:
googleMap.setMyLocationEnabled(false);
New button onClick method content:
googleMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(googleMap.getMyLocation().getLatitude(),
googleMap.getMyLocation().getLongitude())));
You can just get the view by its id and re-set the top margin Apparently the id is always 2, but this isn't documented and your app will break when/if the id ever changes. Like Pavel said, it's safer to make your own location button and wire it up.
Unfortunately, calling ActionBar.getHeight() in your onCreate will always return 0 since layout hasn't finished. The way to get the real heigh is by using a listener on the ViewTreeObserver:
mainLayout.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
int actionBarHeight = getActionBar().getHeight();
// TODO: set margin of views dependent on actionbar height
// remove the listener
mainLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
}