反应原生:在FlatList反向zIndex的

问题描述 投票:1回答:1

我有一些元素,其中所述顶部元件应该重叠的底部元件的FlatList。对于这一点,我想扭转zIndex的,但FlatList不断改写我的zIndex的。

在下面我的代码试图扭转与qazxsw POI的Z指数,但它不工作

zIndex: 0 - index

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", }, });

link to Expo Snack

android ios react-native z-index react-native-flatlist
1个回答
0
投票

我没有设法与zIndex的的帮助下做到这一点,因为这个问题似乎是从索引设置zIndex的,它只是似乎没有工作。

我成功地做到这一点,将是反转的FlatList,以及使用的翻转列弯曲方向的风格,使得它实际上是滚动到顶部为好。请注意,这将有效地显示也以相反的顺序帖子,所以翻转底层阵列将需要达到想要的结果

output
© www.soinside.com 2019 - 2024. All rights reserved.