HarmonyOS 监听折叠状态回调里获取屏幕宽度存在问题

HarmonyOS 监听折叠状态回调里获取屏幕宽度存在问题

HarmonyOS
2024-08-07 11:25:11
703浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
数掉几只鱼

示例代码

onFoldDisplayMode() {
let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => {
if (data === display.FoldDisplayMode.FOLD_DISPLAY_MODE_FULL) {
console.log (`FOLD_DISPLAY_MODE_FULL width is ${display.getDefaultDisplaySync ().width}`)
}
else if (data === display.FoldDisplayMode.FOLD_DISPLAY_MODE_MAIN) {
console.log (`FOLD_DISPLAY_MODE_MAIN width is ${display.getDefaultDisplaySync ().width}`)
}
else if (data === display.FoldDisplayMode.FOLD_DISPLAY_MODE_SUB) {
console.log (`FOLD_DISPLAY_MODE_SUB width is ${display.getDefaultDisplaySync ().width}`)
}
else {
console.log (`FOLD_STATUS_UNKNOWN width is ${display.getDefaultDisplaySync ().width}`)

}
console.info ('Listening enabled. Data: ' + JSON.stringify (data));
};
try {
display.on ('foldDisplayModeChange', callback);
} catch (exception) {
console.error ('Failed to register callback. Code: ' + JSON.stringify (exception));
}
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
分享
微博
QQ
微信
回复
2024-08-07 15:55:19


相关问题
HarmonyOS 折叠获取屏幕尺寸问题
570浏览 • 1回复 待解决
HarmonyOS 位置权限变更监听问题
820浏览 • 1回复 待解决
HarmonyOS 屏幕亮度变化
547浏览 • 1回复 待解决
HarmonyOS 折叠屏webview宽度问题
987浏览 • 1回复 待解决
HarmonyOS 如何监听折叠/展开状态
648浏览 • 1回复 待解决
HarmonyOS 屏幕宽度怎么获取
899浏览 • 1回复 待解决
HarmonyOS 网络监听多次
706浏览 • 1回复 待解决
HarmonyOS 折叠状态获取
569浏览 • 1回复 待解决
HarmonyOS 折叠监听问题
549浏览 • 1回复 待解决