相互渲染平面项目(重叠)

时间:2020-06-04 13:21:37

标签: android reactjs react-native

我想实现下图所示的功能,但我不知道使平面列表项彼此重叠: enter image description here

忘记左右图标了,我只是想问一个中间容器的方法,该容器具有彼此渲染的卡片。提前tnx

1 个答案:

答案 0 :(得分:1)

工作示例:https://snack.expo.io/@msbot01/sponaneous-salsa

export default function App() {
  return (
    <View style={styles.container}>
      <View style={{flexDirection:'row', justifyContent:'flex-end', backgroundColor:'white', paddingTop:10, paddingBottom:10}}>
        <View style={{backgroundColor:'transparent'}}>
          <View style={[styles.shadow, {backgroundColor:'red', borderTopLeftRadius:40, borderBottomLeftRadius:40}]}>
            <Text style={styles.paragraph}>
              First
            </Text>
          </View>
        </View>
        <View style={{backgroundColor:'red', borderBottomWidth:0, borderColor:'white'}}>
          <View style={[styles.shadow, {backgroundColor:'red', borderTopLeftRadius:40, borderBottomLeftRadius:40}]}>
            <Text style={styles.paragraph}>
              second  
            </Text>
          </View>
        </View>
        <View style={{backgroundColor:'red', borderBottomWidth:0, borderColor:'white'}}>
          <View style={[styles.shadow, {backgroundColor:'red', borderTopLeftRadius:40, borderBottomLeftRadius:40}]}>
            <Text style={styles.paragraph}>
              third
            </Text> 
          </View>
        </View>
      </View>

    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
  shadow:{
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 0.8,
    shadowRadius: 4,  
    elevation: 5
  }
});
相关问题