react-native-safe-area-context
react-native-safe-area-context copied to clipboard
Add documentation to enable notch on android
It might be convenient to include the needed android config to enable notches here
Add these lines to MainActivity.java
import android.view.WindowManager;
import android.os.Build;
import android.os.Bundle;
...
protected void onCreate(Bundle savedInstanceState) { <-- existing
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(layoutParams);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
super.onCreate(savedInstanceState); <-- existing
...
Credit: https://dev.to/brunolemos/adding-notch-support-to-your-react-native-android-app-3ci3 https://stackoverflow.com/a/29311321
For samsung not changes all headerTitle content on top screen
Edit, this code works better.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Window w = getWindow();
w.setStatusBarColor(Color.TRANSPARENT);
w.setNavigationBarColor(Color.TRANSPARENT);
w.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
https://unicorn-utterances.com/posts/draw-under-navbar-using-react-native/
Thank you so much for these links! I had a bad time trying to achive this.
PRs would be really appreciated here