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

一流的网站建设哪家好什么是软文推广

一流的网站建设哪家好,什么是软文推广,太原建站一条龙,响应式网站怎么样【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.fp688.cn/news/160538.html

相关文章:

  • 毕业设计代做网站机械成都排名推广
  • 建设部网站关于公租房网站服务器多少钱一年
  • 兰州做网站网站链接交易
  • 东莞东城网站建设公司网络推广的细节
  • 做视频网站需要什么苏州排名搜索优化
  • 苏州高端网站制作机构seo是什么意思 职业
  • 做网站 异地域名核心关键词和长尾关键词举例
  • 赣州网站建设-赣州做网站南宁百度推广代理商
  • 重庆中技互联seo优化排名经验
  • 属于免费的网络营销方式西安关键词优化服务
  • 网站公安备案公告深圳推广公司排行榜
  • seo网站描述黑帽seo培训多少钱
  • 做威客的网站百度seo sem
  • 怎么搜索网站内容新东方雅思培训机构官网
  • 免费的企业建站cms网络营销的方式和手段
  • 网站开发的合同电子商务seo是什么意思
  • 甘肃省建设工程安全质量监督局网站友链交易交易平台
  • 提供做pc端网站千锋教育可靠吗
  • 做网站有什么工具博客营销
  • 制作短链接网站关键词汇总
  • python做笔记的网站百度加盟
  • 汝南县网站建设seo就业哪家好
  • 云主机 网站 多个二级域名 seo优化文军seo
  • 工商工事上哪个网站做seo优化查询
  • 网站视频做栏目一般一期多钱商务软文写作范文200字
  • 做哪些网站可以赚钱的西安网络推广
  • 找货源的网上平台有哪些优化加速
  • phpcms 怎么做网站台州seo公司
  • 福州微信营销网站建设店铺运营
  • 网站源码下载后怎么用福州seo经理招聘