在HarmonyOS NEXT开发中responseRegion设置上下浮动50%,下半部分未生效?代码示例如下
Column() {
Blank().height(200)
Text("按钮1").onClick(() => {})
.height(60)
.stateStyles({
pressed: {
.backgroundColor(Color.Red)
},
normal: {
.backgroundColor(Color.Blue)
}
})
.responseRegion({ x: 0, y: '-50%', width: '100%', height: '200%' })
Blank().height(30)
}
这里的Blank组件存在遮挡,类似Stack内元素的zIndex遮挡,可以使用以下两种方案
1、将Blank组件替换为Row组件
2、对Text组件设置zIndex(1),将Text层级设置到顶层,demo示例如下: