相关疑难解决方法(0)

React native,ScrollView的子项不会填满整个高度

所以我在视图的顶部有一个水平滚动视图.ScrollView包含具有指定宽度的节点.然后我在ScrollView的底部有一个边框,就像你可以在这个屏幕上看到的那样:http://i.imgur.com/pOV1JFP.png

如您所见,顶部ScrollView的子节点未到达边框.但是,如果我将ScrollView更改为View with flexDirection: 'row',则子节点将填充高度.我尝试在scrollview上更改一些属性,例如:

  • 设置padding:0contentContainerStyle
  • automaticallyAdjustContentInsets={false}
  • contentInsets直接改变值

似乎没有人解决这个问题.

scrollview代码和样式:

var styles = StyleSheet.create({
  nav: {
    padding: 0,
    marginTop: 30,
    flex: 1,
    borderBottomWidth: 1,
    borderColor: '#000000'
  }
});

<ScrollView
  style={[{width: screen.width}, styles.nav]}
  horizontal={true}
  showsHorizontalScrollIndicator={true}
  automaticallyAdjustContentInsets={false}>
  {dayNavItems}
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

子组件(组成dayNavItems)

const styles = StyleSheet.create({
  container: {
    paddingLeft: 15,
    paddingRight: 15,
    width: 50,
    justifyContent: 'center'
  },
  odd: {
    backgroundColor: '#ccc'
  },
  selected: {
    backgroundColor: '#39b54a'
  },
  text: {
    fontFamily: 'Optima'
  }
});

class DayNavItem extends …
Run Code Online (Sandbox Code Playgroud)

flexbox react-native

17
推荐指数
5
解决办法
8352
查看次数

标签 统计

flexbox ×1

react-native ×1