ReactNative: how to center text?

前端 未结 16 832
终归单人心
终归单人心 2020-12-22 18:40

How to center Text in ReactNative both in horizontal and vertical?

I have an example application in rnplay.org where justifyContent=\"center\" and

16条回答
  •  鱼传尺愫
    2020-12-22 18:58

    You can use two approaches for this...

    1. To make text align center horizontally, apply this Property (textAlign:"center"). Now to make the text align vertically, first check direction of flex. If flexDirection is column apply property (justifyContent:"center") and if flexDirection is row is row apply property (alignItems : "center") .

    2. To Make text align center apply same property (textAlign:"center"). Now to make it align vertically make the hieght of the equal to view and then apply property (textAlignVertical: "center")...

    Most Probably it will Work...

提交回复
热议问题