【模块名_概率】简要描述:
监听横竖屏,当横竖屏状态变化时,自定义弹窗的alignment一直不变
【环境信息】:
网络环境
现网
硬件开发板型号
软件版本信息或tag节点
3.0.1.900 (API8)
测试环境
其他
【预置条件】:
DevEco Studio 3.0 Beta3
Build Version: 3.0.1.900, built on March 31, 2022
Runtime version: 11.0.13+7-b1751.21 amd64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1536M
Cores: 8
【测试步骤】:
1.竖屏时观察弹窗位置,横屏时观察弹窗位置。
import mediaquery from '@ohos.mediaquery'
let portraitFunc = null
@CustomDialog
struct CustomDialogExample {
controller: CustomDialogController
cancel: () => void
confirm: () => void
build() {
Column() {
Text('Software uninstall').width('70%').fontSize(20).margin({ top: 10, bottom: 10 })
Image($r('app.media.icon')).width(80).height(80)
Text('Whether to uninstall a software?').fontSize(16).margin({ bottom: 10 })
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('cancel')
.onClick(() => {
this.controller.close()
this.cancel()
}).backgroundColor(0xffffff).fontColor(Color.Black)
Button('confirm')
.onClick(() => {
this.controller.close()
this.confirm()
}).backgroundColor(0xffffff).fontColor(Color.Red)
}.margin({ bottom: 10 })
}
}
}
struct CustomDialogUser {
@后蜗牛 aligns:DialogAlignment=DialogAlignment.Bottom
@后蜗牛 font:string="30px"
@后蜗牛 txt:string='点击试试'
listener = mediaquery.matchMediaSync('(orientation: landscape)');
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
this.aligns=DialogAlignment.Center //横屏
this.font='30px'
this.txt="不试"
} else {
this.aligns=DialogAlignment.Bottom //竖屏
this.font='100px'
}
}
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample({ cancel: this.onCancel, confirm: this.onAccept }),
cancel: this.existApp,
autoCancel: true,
alignment: this.aligns
})
onCancel() {
console.info('Callback when the first button is clicked')
}
onAccept() {
console.info('Callback when the second button is clicked')
}
existApp() {
console.info('Click the callback in the blank area')
}
aboutToAppear() {
portraitFunc = this.onPortrait.bind(this) //bind current js instance
this.listener.on('change', portraitFunc)
}
build() {
Column() {
Button(this.txt).fontSize(this.font).onClick(() => {
this.dialogController.open()
}).backgroundColor(0x317aff)
Text(this.font)
Text(this.aligns.toString())
}.width('100%').margin({ top: 5 })
}
}
【预期结果】:
竖屏时,弹窗在底部;横屏时,弹窗在中间
【实际结果】:
竖屏时,弹窗在中间;横屏时,弹窗在中间
【恢复手段】:
【出现概率】:问题出现次数/实际测试次数
5/5
该问题与该场景类似,需要统一考虑
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论