Text实现scroll效果怎么弄?

需要使用eTs实现text段落在固定height中可以有scroll效果。

Scroll(this.scroller) {
  Column() {
    Text("This text box is scrollable thanks to being situated inside a nested scroll view. That makes it scrollable regardless of the scrolling of the content of the entire screen, which can be scrolled independently.\nThe point here is to demonstrate how the over-scroll effect can work in the presence of nested scroll-views, provided it is applied over the parent (root) view, regardless of having inner nested scroll-views as children.\nIn this demo, the root view is merely a ScrollView, and therefore applying the effect over it is straightforward (i.e. using the OverScrollHelper).")
      .width("100%").height("100%").textOverflow({ overflow: TextOverflow.None })
      .fontSize(22).fontWeight(600).fontColor("#727171")
  }.padding(14).width("100%").height(200)
}.scrollBar(BarState.Off)

上述代码子组件的height明显大于父组件,但是没有滚动效果。

鸿蒙
滚动
Text
2022-03-18 13:00:43
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Sampso
1

问题已解决,在外面再嵌套一层布局,设置height就行了

Column() {
  Scroll(this.scroller) {
    Flex() {
      Text("This text box is scrollable thanks to being situated inside a nested scroll view. That makes it scrollable regardless of the scrolling of the content of the entire screen, which can be scrolled independently.\nThe point here is to demonstrate how the over-scroll effect can work in the presence of nested scroll-views, provided it is applied over the parent (root) view, regardless of having inner nested scroll-views as children.\nIn this demo, the root view is merely a ScrollView, and therefore applying the effect over it is straightforward (i.e. using the OverScrollHelper).")
        .fontSize(22).fontWeight(600).fontColor("#727171")
    }.padding(14).width("100%")
  }.scrollBar(BarState.Off)
}.width("100%").height(200)
分享
微博
QQ
微信
回复
2022-03-18 14:17:31
相关问题
想把APK文件转成HAP怎么弄
162浏览 • 2回复 待解决
Mysql 同时修改多个库的数据怎么弄
1809浏览 • 1回复 待解决
ability被异常杀后数据保留怎么弄
3854浏览 • 1回复 待解决
如何实现scroll、list单边回弹效果
33浏览 • 1回复 待解决
tabs结合scroll实现吸顶效果
497浏览 • 1回复 待解决
如何去掉Scroll回弹效果
313浏览 • 1回复 待解决
应用怎么实现半模态效果
952浏览 • 1回复 待解决
鸿蒙中怎么实现动画翻转效果
9047浏览 • 2回复 待解决
ArkTS实现Text文本的【...展开】
419浏览 • 1回复 待解决
仿照keyframes实现效果
20浏览 • 1回复 待解决
实现层叠广告滑动效果
428浏览 • 1回复 待解决
长按实现各类振动效果
387浏览 • 1回复 待解决
Navigation实现Tabs切换效果
558浏览 • 1回复 待解决
如何实现动画转场效果
427浏览 • 1回复 待解决
如何实现视频滤镜效果
866浏览 • 1回复 待解决
canvas如何实现水印效果
427浏览 • 1回复 待解决
如何实现星级评分效果
104浏览 • 1回复 待解决