react-native icon indicating copy to clipboard operation
react-native copied to clipboard

overflow:hidden is not supported on Android

Open xinthink opened this issue 11 years ago • 59 comments

When the parent view (overflow: 'hidden') has borderRadius set, the child view is not clipped to the shape of the parent.

2015-10-02 11 31 06

demo reproducing the issue: https://rnplay.org/apps/69TRrw

xinthink avatar Oct 02 '15 15:10 xinthink

Thanks for the report. Unfortunately overflow: hidden is not respected on android (see https://facebook.github.io/react-native/docs/known-issues.html#the-overflow-style-property-defaults-to-hidden-and-cannot-be-changed-on-android). I think @kmagiera has previously posted about the clipping issue for rounded corners and can chime in here.

astreet avatar Oct 02 '15 16:10 astreet

Nothing more to add here. Unfortunately this is a known problem and is not being worked on as mentioned in the docs. Closing this as it's already on the list. If you guys have any proposal on how this could be implemented without causing significant perf issue in rendering pipeline feel free to reopen and post your ideas here

kmagiera avatar Oct 05 '15 09:10 kmagiera

We're using imgix, so I think we'll be able to add ?fm=png&mask=ellipse and be on our way. Dodged a bullet there but will encounter moderate problems elsewhere.

I'll submit a PR to note that in addition to hidden always being true, it doesn't obey borderRadius, which is not currently noted in the docs. (I assumed that if hidden were true, it would be clipped by the borderRadius just fine.)

rreusser avatar Nov 20 '15 17:11 rreusser

@kmagiera May I ask where to find the comment or discussion about clipping issue with rounded corners that you posted before?

Kudo avatar Jan 20 '16 15:01 Kudo

@Kudo: I was referring to the link posted by Andy just above my comment: https://facebook.github.io/react-native/docs/known-issues.html#the-overflow-style-property-defaults-to-hidden-and-cannot-be-changed-on-android

kmagiera avatar Jan 26 '16 21:01 kmagiera

@kmagiera I see. The feature is really useful for some cornered UI construction. Would like to know more detail of your mentioned significant perf drops and see if we can make this feature happens.

Kudo avatar Jan 27 '16 17:01 Kudo

More info: this demo (https://rnplay.org/apps/WlY9aA) shows if the outer control is an image, the borderRadius property will totally not working.

raymanyoung avatar Mar 24 '16 11:03 raymanyoung

We're working on an alternative UI implementation on Android that will fix this -- it's still in testing internally so don't expect it for a few more months, but do know we are working on getting a fix.

astreet avatar Mar 24 '16 12:03 astreet

Any updates on this issue ?

viju85 avatar Apr 13 '16 07:04 viju85

I have a fairly cringe-worthy fix using styles that works for me in the meantime. This is a UI for creating group avatars out of user avatars. Similar to Facebook Messengers group avatars.

https://rnplay.org/apps/qXLzlw

bsinc avatar Apr 14 '16 19:04 bsinc

@bsinc that's a great solution! thx. just clarifying what you did:

  <View style={styles.circle}>
            <Image style={styles.image} />
            <View style={styles.fixCircleClipping}/>

          </View>

  circle: {
    width: circleSize,
    height: circleSize,
    borderRadius: circleSize / 2,
    overflow: 'hidden',
  },
  fixCircleClipping: {
    position: 'absolute',
    top: -circleFixBorder,
    bottom: -circleFixBorder,
    right: -circleFixBorder,
    left: -circleFixBorder,
    borderRadius: circleSize / 2 + circleFixBorder / 2,
    borderWidth: circleFixBorder,
    borderColor: bgColor
  },

yonatanmn avatar Apr 25 '16 15:04 yonatanmn

@bsinc That's brilliant, thank you!

maikokuppe avatar Jun 06 '16 09:06 maikokuppe

@astreet Is there any updates? Thanks

joypatel04 avatar Aug 03 '16 03:08 joypatel04

Is this still a known issue? I can't find the known issues page anymore.

msafi avatar Aug 09 '16 00:08 msafi

@astreet this will be fixed in 0.32? When 0.32 comes out?

Danielduel avatar Aug 13 '16 14:08 Danielduel

@Duelsik Was this hinted to being fixed in 0.32 or are you just asking? The release notes for 0.32 do not mention it anywhere.

julienvincent avatar Aug 16 '16 19:08 julienvincent

Hey all, sorry you are being hit by this -- a couple engineers at FB are actively working on open sourcing our internal fix for this, but it's not a simple change so unfortunately it'll take a while longer. Tentatively, they are hoping to have it open sourced by the end of the year.

astreet avatar Aug 23 '16 20:08 astreet

@astreet Thanks for the info! I eagerly await the fix!

I wonder if there is some temporary hack I can do with css to imitate this? The fix mentioned by @yonatanmn doesn't cover all cases.

julienvincent avatar Aug 23 '16 21:08 julienvincent

@bsinc Thank you!

KristoferEng avatar Aug 25 '16 17:08 KristoferEng

I would also be interested in a temporary hack to fix this problem.

sscaff1 avatar Aug 30 '16 16:08 sscaff1