I tried using Flatlist and it did not work either. On FlatList it will not display the images, so I was not able to test it. On ScrollView it is displaying, but it does not scroll. Here is the code that I have, please help:
import { ScrollView, StyleSheet, View, Image } from "react-native";
import React from "react";
const StylistFeatures = ({ businessFeatures }) => {
const { wifi, walkIn, appointments, toHome, celebrityStylist, covidMask } =
businessFeatures;
return (
<View
style={{
alignSelf: "center",
flexDirection: "row",
width: "100%",
height: "14%",
}}
>
<ScrollView
horizontal
scrollEnabled
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.contentContainerFlatListStyle}
style={{ flexGrow: 1, padding: 10 }}
>
<View style={styles.imageContainerStyle}>
{wifi ? (
<Image
source={require("../assets/images/design-icon/wifi.png")}
style={styles.imageStyle}
/>
) : null}
</View>
<View style={styles.imageContainerStyle}>
{walkIn ? (
<Image
source={require("../assets/images/design-icon/walk.png")}
style={styles.imageStyle}
/>
) : null}
</View>
<View style={styles.imageContainerStyle}>
{appointments ? (
<Image
source={require("../assets/images/design-icon/calendar.png")}
style={styles.imageStyle}
/>
) : null}
</View>
<View style={styles.imageContainerStyle}>
{toHome ? (
<Image
source={require("../assets/images/design-icon/car.png")}
style={styles.imageStyle}
/>
) : null}
</View>
<View style={styles.imageContainerStyle}>
{celebrityStylist ? (
<Image
source={require("../assets/images/design-icon/celebrity.png")}
style={styles.imageStyle}
/>
) : null}
</View>
<View style={styles.imageContainerStyle}>
{covidMask ? (
<Image
source={require("../assets/images/design-icon/safety-mask.png")}
style={styles.imageStyle}
/>
) : (
<Image
source={require("../assets/images/design-icon/no-mask.png")}
style={styles.imageStyle}
/>
)}
</View>
</ScrollView>
</View>
);
};
export default StylistFeatures;
const styles = StyleSheet.create({
contentContainerFlatListStyle: {
width: "100%",
alignItems: "center",
height: "100%",
},
imageStyle: {
width: 40,
height: 40,
margin: 5,
},
imageContainerStyle: {
marginRight: 12,
borderColor: "black",
borderWidth: 1,
borderRadius: 10,
},
});
Please help me, is there a reason why? Is it something bad creating the no scroll?
CodePudding user response:
Try removing the "contentContainerFlatListStyle" width property and try again. Like below. It should work. Let me know how it goes.
contentContainerFlatListStyle: {
alignItems: "center",
height: "100%",
},