Skip to content

Add documentation to enable notch on android #216

Description

@nschild

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions