我有一个SectionList,其中第一个和第二个部分是水平可滚动的.我已经通过在这些部分中嵌套了一个FlatList来做到这一点.然而,将水平填充添加到FlatList,使其从左侧开始16px,也会从右侧删除16px.
我试着把horizontalPadding: 16
换成paddingLeft: 16
&paddingStart: 16
,但结果是一样的.
下面的插图或预期与实际
代码
<SectionList
sections={sections}
renderSectionHeader={({ section }) => {
const type = section.type;
switch (type) {
case "one":
return (
<FlatList
style={{
paddingHorizontal: 16,
marginBottom: 16,
}}
data={section.data}
horizontal
renderItem={({ item }) => <Card1 item={item} />}
ItemSeparatorComponent={() => (
<View style={{ width: 8 }}></View>
)}
showsHorizontalScrollIndicator={false}
/>
);
case "two":
return (
<FlatList
style={{ flex: 1, paddingLeft: 16, marginBottom: 24 }}
data={section.data}
horizontal
renderItem={({ item }) => (
<Card2 item={item} onPress={offerDetails} />
)}
ItemSeparatorComponent={() => (
<View style={{ width: 16 }}></View>
)}
showsHorizontalScrollIndicator={false}
/>
);
case "three":
return (
<Text
style={{
fontSize: 21,
fontWeight: "bold",
paddingHorizontal: 16,
marginBottom: 12,
}}
>
{section.title}
</Text>
);
}
}}
renderItem={({ item, section }) => {
if (section.horizontal) {
return null;
}
return <Card3 item={item} onPress={offerDetails} />;
}}
stickySectionHeadersEnabled={false}
showsVerticalScrollIndicator={false}
/>