HarmonyOS 地图怎么单独全屏显示

不想在EntryAbility里面设置整个app全屏,只想设有HarmonyOS地图的界面全屏,父组件是:

build() {
  Stack() {
    HuaWeiMapComponent(this.mapListenerController)
  }
  .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

子组件集成了HarmonyOS地图如下:

build() {
  Stack() {
    MapComponent({ mapOptions: this.mapOption, mapCallback: this.callback, customInfoWindow: this.customInfoWindow })
      .width('100%')
      .height('100%')
  }.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

地图不能全屏,状态栏上面还是白色的。

HarmonyOS
2024-12-24 16:38:33
938浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

可以使用setWindowLayoutFullScreen()接口设置全屏,通过getLastWindow获取当前应用内最上层的子窗口,若无应用子窗口返回应用主窗口。只实现某个页面的全屏,可以在aboutToapear设置全屏在aboutToDisApear设置恢复,示例参考如下:

import window from '@ohos.window';
import { router } from '@kit.ArkUI';

@Entry
@Component
struct TabPage {
  @State message: string = 'Hello World';

  setFullScreen(status: boolean) {
    window.getLastWindow(getContext(this)).then((window) => {
      window.setWindowLayoutFullScreen(status)
    })
  }

  aboutToAppear(): void {
    // 出现和消失这里调用具体逻辑
  }

  aboutToDisappear(): void {
  }

  build() {
    Column() {
      Text(this.message)
        .id('HelloWorld')
        .fontSize(50)
        .fontWeight(FontWeight.Bold)
        .onClick(() => {
          // readerModeCb(null,)
          router.back()
        })

      Button("设置沉浸式").onClick(() => {
        this.setFullScreen(true)
      })
      Button("取消设置沉浸式").onClick(() => {
        this.setFullScreen(false)
      })
    }
    .backgroundColor("#ffde8242")
    .height('100%')
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
分享
微博
QQ
微信
回复
2024-12-24 20:03:29
相关问题
HarmonyOS 华为地图全屏
713浏览 • 1回复 待解决
HarmonyOS 显示不出地图
518浏览 • 1回复 待解决
HarmonyOS 地图显示效果
608浏览 • 1回复 待解决
HarmonyOS 地图城市显示问题
615浏览 • 1回复 待解决
HarmonyOS 华为地图显示
1305浏览 • 1回复 待解决
HarmonyOS webvideo禁用全屏显示问题
862浏览 • 1回复 待解决
HarmonyOS 地图显示不完全
1024浏览 • 1回复 待解决
HarmonyOS 页面如何设置全屏显示
2097浏览 • 1回复 待解决
startWindowIcon可以设置全屏显示吗?
2253浏览 • 1回复 待解决
鸿蒙app使用js显示地图
8503浏览 • 1回复 待解决
如何禁用窗口的全屏显示功能
2411浏览 • 1回复 待解决
HarmonyOS 使用 api11 地图显示
1403浏览 • 1回复 待解决
@kit.MapKit 地图控件无法显示
2980浏览 • 1回复 待解决