Last Updated on : 2024-06-05 03:14:35download
This topic describes the utility method that is used to proportionally scale a component of your app to adapt to different mobile screens.
RatioUtils
Proportionally scale a component of your app to adapt to different mobile screens. This allows Android or web apps to support varied screen parameters such as width.
Name | Description |
---|---|
hRatio | The horizontal ratio of the screen. It is the width ratio of the current mobile screen to an iPhone6 screen. |
vRatio | The vertical ratio of the screen. It is the height ratio of the current mobile screen to an iPhone6 screen. |
width | The width of the current screen. |
height | The height of the current screen. |
ratio | The diagonal line ratio of the current mobile screen to an iPhone6 screen. |
convertX | Use hRatio to calculate the width of a component. |
convertY | Use vRatio to calculate the height of a component. |
convert | Use ratio to calculate the diagonal line of a component. |
isIos | Specify whether the iOS is used. |
import { Utils } from "tuya-panel-kit";
const { convertX } = Utils.RatioUtils;
// The designed width of the component is set to 13.
width = convertX(13); // The width of the component that appears on the current mobile screen.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback