ArkUI如何支持表冠滚动Scroll组件?
·
需要在Scroll组件里有一个onClick,否则无法成功获得焦点
这样没有onClick是不行的
import { LengthMetrics } from '@kit.ArkUI'
@Entry
@ComponentV2
struct Index {
private scrollerForScroll: Scroller = new Scroller()
build() {
Flex() {
Scroll(this.scrollerForScroll) {
Column() {
Text("Scroll Area")
.width("100%")
.height("200fp")
.backgroundColor(0X330000FF)
.fontSize(16)
.textAlign(TextAlign.Center)
Text("Scroll Area")
.width("100%")
.height("200fp")
.backgroundColor(0X330000FF)
.fontSize(16)
.textAlign(TextAlign.Center)
}
}
.focusable(true)
.defaultFocus(true)
.focusOnTouch(true)
.edgeEffect(EdgeEffect.Spring)
.width("100%").height("100%")
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding(20)
}
}
这样有onClick是可以的
import { LengthMetrics } from '@kit.ArkUI'
@Entry
@ComponentV2
struct Index {
private scrollerForScroll: Scroller = new Scroller()
build() {
Flex() {
Scroll(this.scrollerForScroll) {
Column() {
Text("Scroll Area")
.width("100%")
.height("200fp")
.backgroundColor(0X330000FF)
.fontSize(16)
.textAlign(TextAlign.Center)
.onClick(() => {
})
Text("Scroll Area")
.width("100%")
.height("200fp")
.backgroundColor(0X330000FF)
.fontSize(16)
.textAlign(TextAlign.Center)
}
}
.focusable(true)
.defaultFocus(true)
.focusOnTouch(true)
.edgeEffect(EdgeEffect.Spring)
.width("100%").height("100%")
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding(20)
}
}
更多推荐


所有评论(0)