How to adjust font size to fit view in React Native for Android?

后端 未结 6 2105
死守一世寂寞
死守一世寂寞 2020-12-16 10:14

How I can make the font size of the text auto change inside a view in react native?

I have text with different lengths, some of which doesn\'t fit the view so decrea

6条回答
  •  执笔经年
    2020-12-16 10:37

    Try this approach. Consider setting the font size according to screen width as following

    width: Dimensions.get('window').width
    

    So in your style try to make a percentage calculation to make the font size fit the screen

    style={
      text:{
         fontSize:0.05*width
      }
    }
    

    this will gonna work for all screens (both Android and IOS)

提交回复
热议问题