What is the default unit of style in React Native?

后端 未结 4 1504
既然无缘
既然无缘 2020-12-13 00:20

I am contributing to an Open Source Project where I am developing Material design for React Native. I am blocked at work,I am unable to make some UI level enhancements w.r.t

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 00:22

    From the docs:

    All dimensions in React Native are unitless, and represent density-independent pixels. Setting dimensions this way is common for components that should always render at exactly the same size, regardless of screen dimensions.

    So yes, units in React Native are in dp. If you want to convert them to pixels, use PixelRatio.getPixelSizeForLayoutSize()

提交回复
热议问题