0

我曾经React Native Elements ListItem渲染我的FlatList. 我想在标题所在的同一行设置 timeago 文本(例如:20 Minutes Ago)。但是当我将字幕行数设置为 5 时,timeago 文本会出现在字幕行中。我怎样才能解决这个问题?

<FlatList
  data={this.props.data}
  renderItem={({item}) => (
    <ListItem
      roundAvatar={true}
      avatar={{uri: item.picture.thumbnail}}
      title={`${item.name.first} ${item.name.last}`}
      titleStyle={styles.title}
      rightTitle="20 Minutes Ago"
      rightTitleStyle={styles.rightTitle}
      rightTitleContainerStyle={styles.rightTitleContainer}
      //  subtitle="This is a sample comment which was commented by the developer."
      subtitleStyle={styles.subtitle}
      subtitleContainerStyle={styles.subtitleContainer}
      subtitleNumberOfLines={5}
      hideChevron={true}
      containerStyle={styles.flatListContainer}
    />
  )}
  keyExtractor={item => item.email}
  ItemSeparatorComponent={this.seperator}
  onRefresh={this.handleRefresh}
  refreshing={this.props.refreshing}
  onEndReached={this.handleLoadMore}
  onEndReachedThreshold={50}
/>
4

1 回答 1

1

正如文档所说,垂直居中默认行为rightTitle

提供 rightTitle 以在按钮右侧显示标题

为此,您可以添加rightTitleContainerStyleas

{position: 'absolute', top: (YOUR_TITLE_FONT_SIZE - YOUR_RIGHT_TITLE_FONT_SIZE) / 2, right: 0}
于 2018-04-06T11:07:09.127 回答