【关键字】
px2vp像素单位转换 / @ohos.app.ability.UIAbility组件 / @ohos.window (窗口)模块 / windowStage.loadContent
【问题描述】
通过getWindowAvoidArea.topRect.heigth获取到状态栏的高度为126,这个高度设置为组件的margintop,在工具类里面通过px2vp 126 = 126, 而在component中转换后得到的值却不一样,是什么原因?
screenutils(hsp): 在entryablity中的onWindowCreate中初始化:
import window from '@ohos.window';
import { LogUtils } from './LogUtils';
import { DS_COMPONENTS_TAG } from '../DSComponentsContants';
export class ScreenUtils {
private static TAG: string = `${DS_COMPONENTS_TAG}-${ScreenUtils.name}`
private static _statusBarHeight: number = 0
private static _navigationBarHeight: number = 0
private static _screenWidth: number = 0
private static _screenHeight: number = 0
private static _contentHeight: number = 0
private static _contentWidth: number = 0
static get statusBarHeight(): number {
return ScreenUtils._statusBarHeight
}
static get navigationBarHeight(): number {
return ScreenUtils._na


1万+

被折叠的 条评论
为什么被折叠?



