Solved Max screen size on Android whithout navigationbar dimension
-
Hi,
I'm just looking for a way to get the maximum size / resolution of the display of an android device where I hide the navigationbar via manifest.xml. The point is that the navigationbar is visible for the first seconds and Qml Screen or QScreen in C++ delivers the display size minus the dimension of the navigationbar. The result is that my app has to resize after the navigationbar disappears and this is disturbing. For me would be helpful either to find a way to get the full display size from beginning without the navigationbar or better to setup it directly propably in Java that the navigationbar is never visible.Does anyone has an idea?
Thanks in advance...
-
I found following solution, which is also recommended under https://developer.android.com/training/system-ui/immersive.html
1.) Open in Qt directory the file QtActivity.java
.....\Qt\Qt5.7.0\5.7\android_armv7\src\android\java\src\org\qtproject\qt5\android\bindings
2.) Fill inpublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m_loader.APPLICATION_PARAMETERS = APPLICATION_PARAMETERS; m_loader.ENVIRONMENT_VARIABLES = ENVIRONMENT_VARIABLES; m_loader.QT_ANDROID_THEMES = QT_ANDROID_THEMES; m_loader.QT_ANDROID_DEFAULT_THEME = QT_ANDROID_DEFAULT_THEME; m_loader.onCreate(savedInstanceState); //######################################################## if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions); } //###################################################### }
and
public void onWindowFocusChanged(boolean hasFocus) { if (!QtApplication.invokeDelegate(hasFocus).invoked) super.onWindowFocusChanged(hasFocus); //########################################################## if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (hasFocus) { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions); } } //################################################################## }
It works perfectly and hope to help someone...
-
@PowerNow thx letting us know
@tero-kojo this kind of stuff should be collected at a central place (we discussed this last year ;-) -
@ekkescorner that's my "home" account for testing purposes.
The wiki would be the right place as a start.