Skip to content

Android does not render a Mask at all #241

Description

@lucksp

Description

I am using:

    "@react-native-masked-view/masked-view": "0.3.2",
    "expo": "~52.0.32",
    "react-native": "0.76.7", // new architecture is disabled

here is my code snippet:

return (
    <View
      style={{
        flex: 1,
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        backgroundColor: 'rgba(0, 0, 0, 0.7)',
      }}
    >
      <MaskedView
        maskElement={
          <View
            style={{
              flex: 1,
              backgroundColor: '#00000077',
            }}
          >
            <View
              style={{
                flex: 1,
                justifyContent: 'center',
                alignItems: 'center',
              }}
            >
              <View
                style={{
                  width: Dimensions.get('window').width / 1.25,
                  height: Dimensions.get('window').width / 1.25,
                  backgroundColor: 'black',
                  borderRadius: 20,
                }}
              />
            </View>
          </View>
        }
        style={{
          flex: 1,
        }}
      >
        <CaptureView
          disableActions={true}
          enableDeviceToggle={false}
          onCapturePhoto={capturePhoto}
          showViewFinder={false}
        />
      </MaskedView>

      {/* Corner Elements */}
      <View
        style={{
          position: 'absolute',
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          justifyContent: 'center',
          alignItems: 'center',
          pointerEvents: 'none',
        }}
      >
        <View
          style={{
            width: Dimensions.get('window').width / 1.25,
            height: Dimensions.get('window').width / 1.25,
            position: 'relative',
          }}
        >
          {/* Top Left */}
          <View
            style={{
              position: 'absolute',
              top: -2,
              left: -2,
              width: 40,
              height: 40,
              borderColor: 'white',
              borderLeftWidth: 4,
              borderTopWidth: 4,
              borderTopLeftRadius: 20,
            }}
          />
          {/* Top Right */}
          <View
            style={{
              position: 'absolute',
              top: -2,
              right: -2,
              width: 40,
              height: 40,
              borderColor: 'white',
              borderRightWidth: 4,
              borderTopWidth: 4,
              borderTopRightRadius: 20,
            }}
          />
          {/* Bottom Left */}
          <View
            style={{
              position: 'absolute',
              bottom: -2,
              left: -2,
              width: 40,
              height: 40,
              borderColor: 'white',
              borderLeftWidth: 4,
              borderBottomWidth: 4,
              borderBottomLeftRadius: 20,
            }}
          />
          {/* Bottom Right */}
          <View
            style={{
              position: 'absolute',
              bottom: -2,
              right: -2,
              width: 40,
              height: 40,
              borderColor: 'white',
              borderRightWidth: 4,
              borderBottomWidth: 4,
              borderBottomRightRadius: 20,
            }}
          />
        </View>
      </View>
    </View>
  );

I saw some other issues that seem related: #226 and #233 but I don't believe it's quite the same or something new has been introduced to cause a break??

Results

  • on iOS it looks perfect: gray mask with center box
  • on Android, there is no mask, but the border box renders OK.

Screenshots:

Image
Image

Notes

  • I tried adding the androidRenderingMode to software and then the entire screen is gray, with no mask applied.
    Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions