简体   繁体   中英

React Native: Notification text not showing up in android

I have a notification badge with text like so:

<View style={styles.notificationBadge}>
  <Text style={styles.notificationText}>
    notification
  </Text>
</View>

When I test this in iOS it works fine and the text appears. But when I test it in Android, nothing appears. Like so:

在此处输入图片说明

Here is the style for notification badge and text:

  notificationBadge: {
    backgroundColor: '#23CCA3',
    borderRadius: 15,
    justifyContent: 'center',
    alignContent: 'center',
    padding: 0,
    marginBottom: 3,
    alignSelf: 'center',
    width: 24,
    height: 24
  },
  notificationText: {
    alignSelf: 'center',
    textAlign: 'center',
    fontSize: 12,
    fontWeight: 'bold',
    lineHeight: 0,
    color: '#fff',
    marginTop: 0
  }

Let me know if you have any ideas on how to fix this.

The text is not displayed due to zero lineHeight. Try this style:

notificationText: {
    alignSelf: 'center',
    textAlign: 'center',
    fontSize: 12,
    fontWeight: 'bold',
    color: '#fff',
    marginTop: 0
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM