appandflow / appandflow/react-native-safe-area-context

Add documentation to enable notch on android

Open
#216 5 comments 1 reaction 0 assignees View on GitHub
good first issue help wanted Platform: Android
Dominant language
TypeScript
Stars
2.8k
Forks
258
Avg merge
3d 1h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.