屏幕物理像素,屏幕像素点(发光点)
1window.innerWidth
设置盒子大小,根据屏幕像素密度,转为屏幕物理密度,默认单位vp,1vp=3px
设置字体大小,跟随系统字体大小变化
逻辑像素单位,1lpx=2px
1@Entry 2@Component 3struct Page02_TaskList { 4 build() { 5 Column() { 6 Text('文本') 7 .fontSize(10) 8 .width(vp2px(100) + "px") 9 .height(100) 10 .backgroundColor("red") 11 12 Text('文本') 13 .fontSize(10) 14 .width('300px') 15 .height('300px') 16 .backgroundColor("blue") 17 18 Text('文本') 19 .fontSize(10) 20 .width('200lpx') 21 .height('200lpx') 22 .backgroundColor("black") 23 24 } 25 .height('100%') 26 .width('100%') 27 } 28}
Copyright ©2010-2022 比特日记 All Rights Reserved.
Powered By 可尔物语