styles.xml:
in android/app/src/main/res/values/styles.xml configure like following:<resources>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:navigationBarColor">#000000</item>
</style>
</resources>
AndroidManifest.xml:
in android/app/src/main/AndroidManifest.xml configure like following:<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<activity
<!-- ... -->
</activity>
<activity
<!-- ... -->
</activity>
<!-- ... -->
</application>
Hiding Navigation Bar:
For making navigation go away completely simply put navigation bar into immersive sticky mode by putting MainActivity.java. In android/app/src/main/java/com/company/MainActivity.java like following://...
import android.os.Bundle;
import android.view.View;
import android.content.res.Configuration;
public class MainActivity extends ReactActivity {
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideNavigationBar();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideNavigationBar();
}
}
private void hideNavigationBar() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
@Override
protected void onResume() {
super.onResume();
hideNavigationBar();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
hideNavigationBar();
}
}
References:
https://facebook.github.io/react-native/docs/statusbar.html
https://developer.android.com/jetpack/androidx/releases/appcompat
No comments:
Post a Comment