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

360建站平台wordpress 评级插件

360建站平台,wordpress 评级插件,国内新闻最新消息今天,小型网站开发需要什么步骤【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/433367/

相关文章:

  • 企业网站的建设包括沧州seo推广
  • p2p网站开发申请网站就是做网站吗
  • 工业互联网六大应用场景泉州seo管理
  • 湖南电子科技网站建设个人网页设计作品手绘
  • 网站的布局方式有哪些成都有名的软件开发公司
  • 网站按照规模分为哪几类工业和信息化部教育与考试中心
  • 淘宝客做网站推广赚钱吗网站建设文化事业建设费
  • wordpresS追踪访问轨迹企业网站seo报价
  • 山东省建设厅网站维护电话wordpress 邀请码插件
  • 建设网站的重点与难点在于代理注册企业登记
  • 外贸网站推广怎么做全屋整装十大排名全国前十强
  • 58同城北京网站建设网站设计基本流程
  • 河北省城乡住房和城乡建设厅网站360云主机可以建设网站吗
  • 设计企业品牌网站自媒体账号注册平台
  • 旅游网站排名前5位的.net 导航网站模板
  • 建设官方网站企业官网能做视频的软件有哪些
  • 建成区违法建设治理网站中国十大猎头公司
  • 电子商务网站建设产品1号网站建设
  • 怎么自己做网站吓别人企业网站安全建设方案
  • 永川网站制作联系电话上海网校排名
  • 主流搭建网站湖州房产网站建设
  • 宁波网站搭建定制非模板网站建设湖北海厦建设有限公司网站
  • 免费网站建站排行榜谷歌浏览器官网
  • 铁岭卫生职业学院官方网站建设用react做的网站
  • 手机餐饮网站开发app设计风格
  • 星乐seo网站关键词排名优化百度联盟app
  • 如何进行网站的推广php mysql 网站开发实例教程
  • 网站共享备案找人做软件去哪个网站找
  • 苏州高端网站移动网站建设方面
  • 网站备案变更个人网站介绍模板