0

I'm trying to put a text into a limited space (yellow container). How to solve this problem in Android?

In iOS the problem is solved with adjustsFontSizeToFit={true}.

My code:

<View
  style={{
    backgroundColor: 'yellow',
    flex: 0.8,
    marginRight: 10,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center'
  }}
>
  <CustomText style={{ fontWeight: '400' }}>{`Qt. ${orderProduct.quantity}`}</CustomText>
    <PriceText
      style={{
        fontWeight: '600',
        fontSize: 18,
        color: '#000'
      }}
      price={price}
    />
</View>
  • This question is very similar to https://stackoverflow.com/questions/48001774/adjusts-font-size-to-fit-view-in-react-native-android – Vinicius Apr 30 '19 at 15:27

1 Answers1

0

Hey consider looking into this. In android native it is done via setting max lines o a text to 1. android:maxLines="1"

Sundus
  • 458
  • 4
  • 12
  • In react native the same thing is done whit numberOfLines={1}, but the result is not what i want. For example if the price is very long then it will be truncated with '...' (12923.3...) – Nico Montanari May 02 '19 at 07:47
  • Yes that's the usual behavior. You must have set the width of layout specific. – Sundus May 02 '19 at 09:55