Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overflow:hidden is not supported on Android #3198

Closed
xinthink opened this issue Oct 2, 2015 · 59 comments
Closed

overflow:hidden is not supported on Android #3198

xinthink opened this issue Oct 2, 2015 · 59 comments
Assignees
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@xinthink
Copy link
Contributor

xinthink commented Oct 2, 2015

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

@astreet
Copy link
Contributor

astreet commented Oct 2, 2015

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.

@kmagiera
Copy link
Contributor

kmagiera commented Oct 5, 2015

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 kmagiera closed this as completed Oct 5, 2015
@rreusser
Copy link
Contributor

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.)

@Kudo
Copy link
Contributor

Kudo commented Jan 20, 2016

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

@kmagiera
Copy link
Contributor

@Kudo
Copy link
Contributor

Kudo commented Jan 27, 2016

@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.

@raymanyoung
Copy link

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

@astreet
Copy link
Contributor

astreet commented Mar 24, 2016

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.

@viju85
Copy link

viju85 commented Apr 13, 2016

Any updates on this issue ?

@bsinc
Copy link

bsinc commented Apr 14, 2016

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

@yonatanmn
Copy link

@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
  },

@maikokuppe
Copy link

@bsinc That's brilliant, thank you!

@joypatel04
Copy link

@astreet Is there any updates?
Thanks

@msafi
Copy link

msafi commented Aug 9, 2016

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

@Danielduel
Copy link

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

@julienvincent
Copy link

@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.

@astreet
Copy link
Contributor

astreet commented Aug 23, 2016

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.

@julienvincent
Copy link

@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.

@desmond1121
Copy link
Contributor

@henrikra Sorry for my misunderstood, removeClippedSubviews would remove out bound sub views but not clip in bound views.. so definitely it's not work with your problem.

@PARAGJYOTI
Copy link

@bsinc it's so smart . Just wanted to add a little advice , never use borderRadius as props (i repeat props , not style) in Image , like

     <Image source={some source} borderRadius={50} /> .

   Just Never !!

Using in scrollview will crash the app on repeated scrolling , and you will ruin the day finding where the bug is , even debugger won't tell you whats wrong . Its may be a out of memory problem . If its not within ScrollView or ListView (not sure), its fine . I almost ruined 4 hours finding the bug . Use the @bsinc trick instead .

@kesha-antonov
Copy link
Contributor

+1 for this to have on android

@mica16
Copy link

mica16 commented May 3, 2017

+1

@madjam002
Copy link

Please upvote on product pains (https://react-native.canny.io/feature-requests/p/add-overflow-support-to-android) or upvote this issue rather than spamming "+1" comments.

@mica16 @diegorodriguesvieira

@miyamatthild
Copy link

I'd just like to throw in another data point for setting zIndex as a workaround (from @saberking's post). I'm working with sprite sheets and ran into the issue where the entire sprite sheet was being shown on Android (worked fine for iOS).

render() {
  return (
    <View style={styles.container}>
      <View style={styles.imageWrapper}>
        <Image
          style={styles.image}
          source={{uri: [...]}}
        />
      </View>
      <Text style={styles.text}>Without zIndex: 1</Text>
      <View style={styles.imageWrapper2}>
        <Image
          style={styles.image}
          source={{uri: [...]}}
        />
      </View>
      <Text style={styles.text}>With zIndex: 1</Text>
    </View>
  );
}

var styles = StyleSheet.create({
  container: {
    backgroundColor: '#f9f8f5',
    flex: 1,
    padding: 20,
    alignItems: 'center'
  },
  imageWrapper: {
    overflow: 'hidden',
    width: 86,
    height: 86
  },
  imageWrapper2: {
    overflow: 'hidden',
    width: 86,
    height: 86,
    zIndex: 1
  },
  image: {
    width: 196,
    height: 86
  },
  text: {
    paddingTop: 10,
    paddingBottom: 30
  }
});

This will render:

zindex

Verified on a Nexus 5 with Android 7.0. Note that you don't need to specify as high a value as 100. Specifying a zIndex of 1 was sufficient to solve the issue for me.

@luco
Copy link

luco commented May 8, 2017

Any update?

This is a must have. Much of UI nowadays is based on rounded corners with subclipping.

@hughnguy
Copy link

Temporary workaround is positioning multiple "absolute" views with a solid border color on top of the image (using z-index) to fill in the gaps. Works if your background is a solid color.

radius

<View style={{height:215, alignItems:'center', flex:1}}>
    <View style={{position:'absolute', height:215, width:deviceWidth*0.95, borderWidth:10, borderRadius: 5, borderColor:'white'}}></View>
    <View style={{position:'absolute', height:215, width:deviceWidth*0.95, borderWidth:10, borderRadius: 20, borderColor:'white'}}></View>
    <Image
        resizeMode="cover"
        style={{height:215, width:deviceWidth*0.9, zIndex:-1}}
        source={this.props.image}
    />
</View>

@PARAGJYOTI
Copy link

Yesterday I suddenly discoveree a simple solution . Just added backgroundColor in Image style and added borderRadius and it worked liked magic. Tried it on android . May be works on IOS too

@wollld
Copy link

wollld commented May 16, 2017

@yonatanmn if borderRadius is 5?

@st0ffern
Copy link

@PARAGJYOTI this is not a solution. look at #3198 (comment) you are refering to the same workaround.

@julienvincent
Copy link

julienvincent commented May 16, 2017

There isn't much more to be said in regard to this issue. Could we please lock conversations on this thread until further development?

@yonatanmn
Copy link

@wollld - what about it? should work as far as I see

@yasserzubair
Copy link

+1

1 similar comment
@EdmundMai
Copy link

+1

@st0ffern
Copy link

st0ffern commented May 18, 2017

Please....
Stop +1 ... Upvote it here: https://react-native.canny.io/feature-requests instead.
Stop spaming workarounds, they dont solve the issue, feel free to create a PR to fix it instead.

Could we please lock the conversation until the issue is solved or there exists a PR to solve it?
@astreet @hramos

@facebook facebook locked and limited conversation to collaborators May 18, 2017
@hramos hramos changed the title [Android] Overflow:hidden not work properly overflow:hidden is not supported on Android Jun 1, 2017
@hramos
Copy link
Contributor

hramos commented Aug 16, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Aug 16, 2017
@hramos hramos closed this as completed Aug 16, 2017
@hramos hramos reopened this Sep 5, 2017
@aaronechiu
Copy link
Contributor

This is fixed with D5917111.

@aaronechiu aaronechiu self-assigned this Sep 30, 2017
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests