Say that I want to create a UI element 2cm*3cm in dimensions, exactly. Also, needles to say, said dimensions would need to be the same on all devices.
I am already using react-native-responsive-screen , but that is not what I am looking for.
I have come upon some solutions, like the one in this thread: Get screen DPI in react native
Reading through it, I made the function below:
(cm)=>{
const dpi = (PixelRatio.get()*160);
const dpCentimeter = dpi/2.54;
return dpCentimeter*cm;
}
However, using it on different devices (specifically using an iPhone 6s and an Huawei honor) the dimensions end up wildly different. Could this be due to the different OS? Is there any other way to get this working as intended?