In React Native, how do I put a view on top of another view, with part of it lying outside the bounds of the view behind?

前端 未结 7 913
一向
一向 2020-12-23 18:50

I\'m trying to make a layout as per below with React Native.

\"enter

How do I

7条回答
  •  盖世英雄少女心
    2020-12-23 19:21

    You can use react-native-view-overflow plugin for placing a view on top of another. It works like the CSS z-index property.

    import ViewOverflow from 'react-native-view-overflow';
    
    
        
        
          userList
        
          
            overflow: "visible"
          
          
            ...
          
        
      
    
    const styles2 = StyleSheet.create({
      cardBox: {
        borderLeftWidth: 0,
        borderTopWidth: 0,
        backgroundColor: "transparent",
        borderWidth: 1,
        borderColor: "#d0d0d0",
        width: '94%',
        alignSelf: 'center',
        height: 200,
        position: "relative",
        borderRadius: 15,
        overflow: "visible" // doesn't do anything
      },
      cardContent: {
        textAlign: "right",
        backgroundColor: "transparent",
        marginTop: 15,
        alignSelf: 'flex-end',
        padding: 5,
      },
      cardHeader: {
        color: '#fff',
        fontFamily: 'Vazir',
        fontSize: 12
      },
      cardItem: {
        backgroundColor: "#3c4252",
        borderRadius: 3,
        position: "absolute",
        top: -10,
        right: -5,
        width: 50,
        height: 20,
        paddingRight: 5,
      },
    })
    

提交回复
热议问题