【问题标题】:what component can set style in react native ?什么组件可以在 react native 中设置样式?
【发布时间】:2017-04-28 15:08:32
【问题描述】:

在我的项目中,我使用 react-swipeable-views-native set swiper,接下来是 listView,swiper 组件具有默认样式

 flex:1

当我设置 listView 样式时

const styles = StyleSheet.create({
    swiperContainer:{
        height: 200,
        flex: 2 
    },
    listContainer:{
        flex:5
    }
})

, 它不起作用,但设置 swiper 组件 flex:0 ,它可以工作,我猜在 react native View,Text 等可以设置样式,但有些人不能设置样式像 listView

【问题讨论】:

    标签: react-native flexbox


    【解决方案1】:

    您需要使用属性contentContainerStyleListView(继承自ScrollView)设置样式。在实践中:<ListView contentContainerStyle={styles.listContainer} ...>

    如果您使用的是 RN 0.43+,我更喜欢使用 FlatList 而不是 ListView

    【讨论】:

      猜你喜欢
      • 2020-06-04
      • 1970-01-01
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 2016-10-11
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      相关资源
      最近更新 更多