AnswerBun.com

can we change status bar or notification bar position programmatically

Stack Overflow Asked by horxCoder on November 17, 2020

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.

2 Answers

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
    )

Answered by Vlad on November 17, 2020

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.

Answered by Ridcully on November 17, 2020

Add your own answers!

Related Questions

Add AWS Cognito to angular application

1  Asked on November 16, 2021 by captainmorgan

     

How to analize which object owns the max memory

0  Asked on November 16, 2021 by loverszhaokai

         

enable_if, SFINAE and template parameters?

2  Asked on November 16, 2021

 

Dynamic ‘wait’ arg in Scrapy-splash

0  Asked on November 16, 2021 by winters

       

Grab a decimal between 2 strings regex

1  Asked on November 15, 2021 by lenny-gonzalez

 

Django , models object not displayed in views

2  Asked on November 15, 2021 by mxzero-mxzero

     

Re-render a sibling component using hooks

3  Asked on November 15, 2021 by programmer1

     

filter method returns empty array

3  Asked on November 15, 2021

     

Fit container inside image

1  Asked on November 15, 2021

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir