Showing
1 changed file
with
22 additions
and
6 deletions
| @@ -39,22 +39,38 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | @@ -39,22 +39,38 @@ ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); | ||
| 39 | 39 | ||
| 40 | ### Use: | 40 | ### Use: |
| 41 | 41 | ||
| 42 | -Adapt screen size: | ||
| 43 | -``` | 42 | +#### Adapt screen size: |
| 43 | + | ||
| 44 | Pass the px size of the design draft: | 44 | Pass the px size of the design draft: |
| 45 | 45 | ||
| 46 | -Width after adaptation: ScreenUtil().setWidth(540), | ||
| 47 | -Height after adaptation: ScreenUtil().setHeight(200), | 46 | +Adapted to screen width: ScreenUtil().setWidth(540), |
| 47 | + | ||
| 48 | +Adapted to screen height: ScreenUtil().setHeight(200), | ||
| 49 | + | ||
| 50 | +**Note** | ||
| 51 | + | ||
| 52 | +Height is also adapted according to setWidth to ensure no deformation (when you want a square) | ||
| 53 | + | ||
| 54 | +setHeight method is mainly adapted in height, you want to control the height and actuality of a screen on the UIUsed when the same is displayed. | ||
| 48 | 55 | ||
| 56 | +``` | ||
| 49 | //for example: | 57 | //for example: |
| 58 | +//rectangle | ||
| 50 | Container( | 59 | Container( |
| 51 | width: ScreenUtil().setWidth(375), | 60 | width: ScreenUtil().setWidth(375), |
| 52 | height: ScreenUtil().setHeight(200), | 61 | height: ScreenUtil().setHeight(200), |
| 53 | ... | 62 | ... |
| 54 | ), | 63 | ), |
| 64 | + | ||
| 65 | +////If you want to display a square: | ||
| 66 | +Container( | ||
| 67 | + width: ScreenUtil().setWidth(300), | ||
| 68 | + height: ScreenUtil().setWidth(300), | ||
| 69 | + ), | ||
| 70 | + | ||
| 55 | ``` | 71 | ``` |
| 56 | 72 | ||
| 57 | -Adapter font: | 73 | +#### Adapter font: |
| 58 | ``` | 74 | ``` |
| 59 | ScreenUtil().setSp(28) //Incoming font size,the unit is pixel, fonts will scale to respect Text Size accessibility settings | 75 | ScreenUtil().setSp(28) //Incoming font size,the unit is pixel, fonts will scale to respect Text Size accessibility settings |
| 60 | ScreenUtil().setSp(28,false) //Incoming font size,the unit is pixel,fonts will not scale to respect Text Size accessibility settings | 76 | ScreenUtil().setSp(28,false) //Incoming font size,the unit is pixel,fonts will not scale to respect Text Size accessibility settings |
| @@ -70,7 +86,7 @@ for example: | @@ -70,7 +86,7 @@ for example: | ||
| 70 | 86 | ||
| 71 | ``` | 87 | ``` |
| 72 | 88 | ||
| 73 | -Other related apis: | 89 | +#### Other related apis: |
| 74 | ``` | 90 | ``` |
| 75 | ScreenUtil.pixelRatio //Device pixel density | 91 | ScreenUtil.pixelRatio //Device pixel density |
| 76 | ScreenUtil.screenWidth //Device width | 92 | ScreenUtil.screenWidth //Device width |
-
Please register or login to post a comment