【问题标题】:Horizontal ScrollView Not Scrolling in React Native水平 ScrollView 在 React Native 中不滚动
【发布时间】:2020-06-30 21:24:10
【问题描述】:

我正在尝试渲染可点击照片的水平滚动视图。 垂直滚动效果很好,但是一旦我设置了 Horizo​​ntal={true},我就限制了我可以水平滚动多远。它使我无法滚动超过this image 中显示的内容。

<Container>
       <ScrollView
      horizontal={true}
      contentContainerStyle={{
        flex: 1,
        paddingTop: "5%"
      }}
    >
      {posts.map(post => {
        return (
          <TouchableOpacity
            key={post.id}
            style={{
              width: width,
              flex: 1,
              height: height / 3,
              borderRadius: "8px",
              overflow: "hidden",
              marginRight: "2%"
            }}
          >
            <Thumbnail
              source={{
                uri: uri`
              }}
            />
            <PostTitle>{post.name}</PostTitle>
          </TouchableOpacity>
        );
      })}
    </ScrollView>
</Container>
const Container = styled.View`
  flex: 1;
  padding-top: 18%;
  background: #fff;
`;

const Title = styled.Text`
  color: #333;
  text-transform: uppercase;
  font-weight: 600;
  padding-left: 8%;
  padding-bottom: 5%;
`;


const Thumbnail = styled.Image`
  flex: 1;
  justify-content: center;
  align-items: center;
  resize-mode: cover;
`;

const PostTitle = styled.Text`
  color: #fdfdfd;
  font-size: 16px;
  font-weight: bold;
  position: absolute;
  top: 10%;
  left: 8%;
`;

【问题讨论】:

    标签: react-native scrollview expo styled-components horizontalscrollview


    【解决方案1】:

    已修复。删除了“marginRight”并且它起作用了。 Horizo​​ntal ScrollView 不喜欢为其子级的边距设置样式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-04
      • 2019-07-16
      • 2018-04-09
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      相关资源
      最近更新 更多