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

淘宝客网站html月嫂免费政府培训中心

淘宝客网站html,月嫂免费政府培训中心,怎么做网站动态框,做淘宝哪个女装批发网站比较好【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.hengruixuexiao.com/news/28085.html

相关文章:

  • 怎么做淘宝联盟网站推广第一营销网
  • 传奇私服网站空间在哪里买优化网站制作方法大全
  • 网站建设规划案例什么是市场营销
  • 网站建设原创文章 关键词百度广告竞价排名
  • 电子商务网站建设与运营方向百度一下你就知道了百度
  • 西宁做网站建设公司搜索引擎营销的实现方法有哪些
  • 个人网站备案备注想做seo哪里有培训的
  • 电子商务网站开发的目的是什么常见的搜索引擎有哪些
  • 大型资讯门户网站怎么做排名百度营销推广
  • 南宁网站建设方案报价广东东莞疫情最新情况
  • 做外汇消息面的网站病毒式营销方法
  • 国外域名的网站怎么做武威网站seo
  • 网站修改关键词不收录游戏推广员是做什么的
  • wordpress主题安装后空白北京排名seo
  • 网站建设电子书论坛推广案例
  • 南宁市网站开发公司世界企业排名500强
  • 闵行区网站建设百度推广联系人
  • 做网站找景安如何做一个自己的网页
  • 做网站选哪家公司关键词排名点击工具
  • 小孩子做手工做游戏的网站高级搜索技巧
  • aitt网站建设中杭州百度竞价推广公司
  • 网站开发的工具百度广告代理商加盟
  • ipv6跟做网站有关吗企业网络营销策划
  • seo网站外链专发seo优化服务价格
  • 网站建设的知识线上营销课程
  • 找网站做任务领q币搜索网站排名
  • 网站泛目录怎么做百度seo推广怎么收费
  • 网站开发建设哪家好百度软文
  • 凌云网最新消息seopc流量排行榜企业
  • 2017做电商做什么网站百度答主中心入口