Skip to content

The default clipChildren (clipToBounds) behaviour is different on android and iOS #10909

@littlesome

Description

@littlesome

hi, this code shows different result on android and iOS:

export default class TestClip extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.child}/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    width: 100,
    height: 100,
    backgroundColor: 'red',
  },
  child: {
    position: 'absolute',
    width: 100,
    height: 100,
    top: 50,
    left: 50,
    backgroundColor: 'green',
  },
});

wechatimg2

I think this is caused by:
on android ViewGroup's clipChildren is true by default,
on iOS UIView's clipToBounds is NO by default.

Tested adding setClipChildren(true) to the base class ReactViewGroup on android can solve this, but not sure if this can cause performance issue. maybe exporting clipChildren as a property on both platform is better?

  • React Native version: 0.37.0
  • Platform: iOS & Android
  • Operating System: MacOS

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