Width is enlarged relative to the design draft => The ratio of font and width to the size of the design Height is enlarged relative to the design draft => The ratio of height width to the size of the design
///Current device width dp
///当前设备宽度 dp
ScreenUtil.screenWidthDp
///Current device height dp
///当前设备高度 dp
ScreenUtil.screenHeightDp
setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling ? setWidth(fontSize) * _textScaleFactor : setWidth(fontSize);
It is recommended to use ScreenUtil.getInstance()
instead of ScreenUtil()
, for example: ScreenUtil.getInstance().setHeight(25)
instead of ScreenUtil().setHeight(25)
setWidth,setHeight,setSp. for example: you can use setWidth(100) or setWidth(100.0)