当前位置: 首页 > news >正文

网站建设赛车网站建设的数据导入导出

网站建设赛车,网站建设的数据导入导出,制作网页网站,网站开发中的paml【HarmonyOS】鸿蒙应用如何进行页面横竖屏切换以及注意事项,自动切换横竖屏,监听横竖屏 一、鸿蒙应用如何进行页面横竖屏调用API手动切换 1.首先要在EntryAbility 中获取主窗口对象 EntryAbility.ets import { AbilityConstant, UIAbility, Want } fr…

【HarmonyOS】鸿蒙应用如何进行页面横竖屏切换以及注意事项,自动切换横竖屏,监听横竖屏

一、鸿蒙应用如何进行页面横竖屏调用API手动切换

1.首先要在EntryAbility 中获取主窗口对象
EntryAbility.ets

import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';export default class EntryAbility extends UIAbility {onWindowStageCreate(windowStage: window.WindowStage): void {// 挂载globalThis上,可以当全局对象使用。当然此处实现方式因人而异,你可以放在单例里,或者localstore中等等globalThis.windowClass = windowStage.getMainWindowSync();windowStage.loadContent('pages/RotationTestPage', (err) => {if (err.code) {return;}});}
}

之后在需要调用横竖屏切换的页面或者逻辑中调用,我这里用按钮触发举例:
RotationTestPage.ets

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

struct RotationTestPage {private TAG: string = "RotationTestPage";onClickRotation = ()=>{// 设置横竖屏状态let orientation = window.Orientation.LANDSCAPE;try{globalThis.windowClass.setPreferredOrientation(orientation, (err: BusinessError) => {if(err.code){console.error(this.TAG, 'Failed to set window orientation. Cause: ' + JSON.stringify(err));return;}console.info(this.TAG,'Succeeded in setting window orientation.');});}catch (exception) {console.error(this.TAG,'Failed to set window orientation. Cause: ' + JSON.stringify(exception));}}build() {RelativeContainer() {Text("点击切换为横屏").id('RotationTestPageHelloWorld').fontSize(50).fontWeight(FontWeight.Bold).alignRules({center: { anchor: '__container__', align: VerticalAlign.Center },middle: { anchor: '__container__', align: HorizontalAlign.Center }}).onClick(this.onClickRotation)}.height('100%').width('100%')}
}

window.Orientation具体数值,参见以下网址

注意:
设置主窗口的显示方向属性。仅在支持跟随sensor旋转的设备上生效,子窗口调用后不生效。

二、如何实现应用的屏幕自动旋转

在module.json5添加属性"orientation": “auto_rotation”。

"abilities": [ { "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:icon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", "exported": true, "skills": [ { "entities": [ "entity.system.home" ], "actions": [ "action.system.home" ] } ], "orientation": "auto_rotation", // 随传感器旋转 } 
]

注意:
auto_rotation随传感器旋转 需要在系统下滑菜单中,放开自动锁定状态才可生效。

三、如何监听屏幕旋转

使用媒体查询接口监听屏幕旋转

import { mediaquery } from '@kit.ArkUI'; 
let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // 监听横屏事件 
function onPortrait(mediaQueryResult: mediaquery.MediaQueryResult) { if (mediaQueryResult.matches) { // do something here } else { // do something here } 
} 
listener.on('change', onPortrait) // 注册回调 
listener.off('change', onPortrait) // 去注册回调
http://www.yayakq.cn/news/833677/

相关文章:

  • 1万流量网站 服务器配置公司做网站价格
  • 梓潼 网站建设 有限公司微信小程序vr全景
  • 监理网站wordpress文章内图片不显示不出来
  • 厦门网站建设厦门seo中型网站流量
  • 做网站编程的待遇重庆永川微网站建设
  • 微信开发网站wordpress微信公众号模板
  • 建设网站的公司哪家好汕头推广平台
  • wordpress直播网站主题网页域名解析错误
  • .net 网站 iis 配置搜索引擎优化的根本目的
  • 做公司网站阿里柳州商城网站开发
  • 公众号兼职网站开发交流平台网站架构怎么做
  • php网站开发工作描述北京 代理前置审批 网站备案
  • 网站建设相关视频教程产品网站免费模板
  • 网站网页的像素尺哪学网页设计
  • 淘宝客网站怎么做优化网站查询平台官网
  • 怎么建商城网站如何规避电子政务网站建设教训
  • 福州seo网站推广优化密友购app开发公司
  • 徐州网站设计价位大庆城乡建设局网站首页
  • 工具类网站做排名网站开发 浏览器
  • seo网站监测深圳品牌网站制作咨询电话
  • 网站开发的背景是指什么苏州建站模板展示
  • 资源专业网站优化排名万维网注册域名后怎么导入网站
  • 建设网站要点wordpress可以干什么
  • 网站建设成本费用新余代网站建设公司
  • 怎么做照片网站汕头seo网站优化
  • 安徽省建设工程信息网站6网站建设立项ppt模板
  • 百度收录率高的网站页面跳转请记住新域名
  • 怎么做监控网站适合发软文的平台
  • 现在网站一般做多大的十大门户网站
  • 东莞美食网站建设报价视觉设计评价标准的要素