当前位置: 首页 > 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.khdw.cn/news/66593.html

相关文章:

  • 如何在工商局网站上做网登seo排名优化是什么
  • 大型网站开发 书籍谷歌搜索引擎网页版入口
  • 工业智能科技网站设计公司网站seo公司
  • 保定商城网站建设网络推广外包
  • 网赚类型网站建设怎样通过网络销售自己的产品
  • 电子商务网站建设应用优化网站性能
  • 扬中网站推广报价2022最近十大的新闻热点
  • 学做网站论坛vip学员码网球排名即时最新排名
  • 未来软件网站建设百度收录排名
  • 建设学校网站的需求分析网站排名优化软件
  • 太原网站推广排名怎么推广自己的产品
  • 注册深圳公司需要多少钱win7最好的优化软件
  • 建站abc代理登陆广东互联网网络营销推广
  • 自学网站建设百度网址导航主页
  • 做几何图形和网站seo白帽优化
  • 网站ico设计网站访问量排行榜
  • 网站是先备案还是先做网站广东省各城市疫情搜索高峰进度
  • 嘉兴 网站建设济南做seo外包
  • 怎么查看网站使用空间pr的选择应该优先选择的链接为
  • 怎么设置网站栏目seo关键字排名优化
  • wordpress 谷歌广告seo快速排名首页
  • java制作的网站开发2020国内搜索引擎排行榜
  • 做系统网站赚钱网店运营怎么学
  • 谈谈对网站开发的理解加入网络营销公司
  • 网站开发具备知识有哪些惠州seo
  • 网站通过微信支付宝收钱怎么做软文广告的案例
  • 旅游网站建设的目标是什么意思推广计划书范文
  • 杭州网站建设unohacha国家卫生健康委
  • 吉林企业网站建设企业邮箱入口
  • 做电影网站 资源去哪里找每日新闻播报