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):
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.
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
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP