镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Background color visible through the border of a border radius #904

Closed

Description

@frostney

When a <View /> component uses backgroundColor and borderRadius, the background color is still visible over the edges of the border.

Screenshot:
reactnative-borderradiusbug

Example code:

var MyComponent = React.createClass({
  render() {
    return <View style={styles.example} />
  }
});

var styles = StyleSheet.create({
  example: {
    backgroundColor: 'white',
    borderRadius: 16,
    borderWidth: 1,
    borderColor: 'black'
  }
});

Activity

  1. brentvatne commented on Apr 17, 2015

    @brentvatne
    Collaborator

    Hi there! Try setting overflow: hidden, does that fix it?

  2. brentvatne commented on Apr 18, 2015

    @brentvatne
    Collaborator

    @frostney - does this still occur on 0.4.0 for you?

    screen shot 2015-04-18 at 4 04 01 pm

    I can only reproduce this when I have some other item inside, eg: , which inherits the background colour of the parent by default and does not have border radius and so it appears to be outside of the rounded corner. You will have to use overflow: hidden as mentioned above to fix that issue.

  3. frostney commented on Apr 20, 2015

    @frostney
    ContributorAuthor

    overflow: hidden does fix it for me. Thank you.
    I hope it's ok that I'm closing this issue.

    Edit: The code example is more stripped down than I intended it to be. This issue occured for me on views (with borderRadius and backgroundColor) that had texts and views as its children (those were without background color or borderRadius) and when I created the code example I forgot to copy over the hierarchy from the production code to the example code while making a screenshot from the production code. Sorry about that.

  4. brentvatne commented on Apr 20, 2015

    @brentvatne
    Collaborator

    @frostney - no problem, glad it helped! 😄

  5. ms88privat commented on Aug 24, 2015

    @ms88privat

    overflow: 'hidden' does fix it for me too.

    Thats not the expected css behaviour. Maybe we should write it in the docs.

    Greetings

  6. nicklockwood commented on Jan 7, 2016

    @nicklockwood
    Contributor

    I believe this now works correctly.

  7. zebulgar commented on Mar 3, 2016

    @zebulgar

    I still have this issue but only with absolutely positioned views. The overflow: 'hidden' works for me as well.

  8. BGuven commented on Apr 11, 2016

    @BGuven

    It is still an issue but overflow: 'hidden' works. Thanks.

  9. uandco commented on Apr 27, 2017

    @uandco

    The issue with overflow is you can't use shadows anymore as they are considered as overflowing elements.

  10. anceque commented on Jun 15, 2017

    @anceque

    as @uandco mentioned, the overflow cannot be used together with shadow properties.. What is the workaround here?

  11. locked as resolved and limited conversation to collaborators on May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions