javascript - 无法查看列表的最后一项

标签 javascript listview react-native react-native-flatlist

我正在使用 FlatList 查看人员列表,但是,我注意到最后一项总是有点偏差:

查看项目 Amy Butts,我必须拖到顶部才能看到它。此屏幕位于具有标题的 stackNavigator 中。那会是问题吗?如何解决?

我在 FlatList 上尝试了 marginBottom: 40 但它没有改变任何东西。

enter image description here

代码:

let renderRow = ({item}) => {
    return (
        <View style={{flexDirection: "row", justifyContent: "space-between"}}>

            <TouchableOpacity style={{ flexDirection: "row", justifyContent: "flex-start", marginLeft: 10}} onPress={this.myFunction.bind(this, item)} >
                <View style={{}}>
                    <Image style={styles.Image} source={{uri: item.Image}} />
                </View>

                <View style={{ marginTop: 15, marginLeft: 10}}>
                    <Text >{item.name}</Text>
                </View>

            </TouchableOpacity>
        </View>
    );
}

return(
    <FlatList style={{marginTop: 10, backgroundColor: "white"}} 
        keyExtractor={(item, index) => item.id}
        data={this.state.result}                          
        renderItem={renderRow.bind(this)} 
        ItemSeparatorComponent={renderSeparator.bind(this)} 
    />
)

使用 paddingBottom(或 top),现在不会显示最后两项:

enter image description here

最佳答案

您需要将 paddingBottommarginBottom 添加到 FlatList 并为您的设计提供合适的值。

// Some padding amount that is suitable for your design
<FlatList style={{marginTop: 10, backgroundColor: "white", paddingBottom: 40}} 
    keyExtractor={(item, index) => item.id}
    data={this.state.result}                          
    renderItem={renderRow.bind(this)} 
    ItemSeparatorComponent={renderSeparator.bind(this)} 
/>

关于javascript - 无法查看列表的最后一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46430291/

相关文章:

php - 以 json 对象形式传递时间戳值以填充流程图

java - 如何将图像放入ListView javafx中

java - Android - 如何将一个扩展名的文件添加到 ListView

react-native - Jest : unexpected token export with react-navigation

android - React native 构建签名 APK 失败

javascript - 带有 Jquery 的 fadeTo 在 Retina Macbook Pro 上的 Chrome 中不起作用

javascript - Angular 过滤表达式

android - Is Recyclerview 最适合不同的List Item View

android - react 原生 : A problem occurred evaluating project ':app' when trying to run on Android

javascript - 为什么数字不是具有 typeof 和 instanceof 的 Number 实例?