Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we change status bar or notification bar position programmatically

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):
enter image description here

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:
enter image description here

i.e. rotate the statusbar according to the sensordata I fetch.

like image 274
horxCoder Avatar asked Sep 19 '20 16:09

horxCoder


People also ask

How can I change my status bar position?

On the Accessibility settings screen, scroll down to “Services section” and tap on Material Status Bar. 2.4. On the next screen, turn ON the Permissions for Material Status Bar by moving the toggle to ON position.

How can change status bar background color in android programmatically?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.

Is the status bar customizable?

Android Status Bar shows time in the top left corner, network signal towards the top right corner, and next to it is your battery icon, but you can customize and add few more things to the little strip to the top of your screen.


1 Answers

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.

like image 146
Ridcully Avatar answered Oct 24 '22 12:10

Ridcully