智能客服
你问我答,随时在线为你解决问题

























问题现象
预览窗口顶部和底部出现白边。

解决措施
这是应用了沉浸式的特性,在沉浸式布局中,状态栏和导航条区域称为避让区,其余区域称为安全区。在默认情况下,开发者的组件被布局在安全区内。如果开发者希望将页面布局应用到全屏窗口,可以采用如下两种方式:
// Index.ets
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Text(this.message)
.id('HelloWorld')
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
}
.height('100%')
.width('100%')
.backgroundColor('#008000')
.expandSafeArea([SafeAreaType.SYSTEM])
}
} // EntryAbility.ets
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err) => {
// ...
});
windowStage.getMainWindow((err, data) => {
if (!err.code) {
data.setWindowLayoutFullScreen(true)
}
});
} 参考链接
智能客服
你问我答,随时在线为你解决问题
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功