【发布时间】:2019-07-03 05:00:28
【问题描述】:
我有一个 FlatList,其中包含一些顶部元素应该与底部元素重叠的元素。为此,我想反转 zIndex,但 FlatList 不断覆盖我的 zIndex。
在下面的代码中,我尝试使用 zIndex: 0 - index 反转 zIndex,但它不起作用
import React, { Component } from "react";
import { FlatList, Text, View, StyleSheet } from "react-native";
export default class App extends React.Component {
_renderPost({ index }) {
return <View style={[styles.item, { zIndex: 0 - index, }]} />;
}
render() {
return <FlatList data={[1, 2, 3, 4, 5,]} renderItem={this._renderPost} />;
}
}
const styles = StyleSheet.create({
item: {
height: 200,
borderWidth:2,
borderBottomLeftRadius:50,
borderBottomRightRadius:50,
marginBottom: -50,
backgroundColor:"white",
},
});
【问题讨论】:
标签: android ios react-native z-index react-native-flatlist