HarmonyOS RichEditor组件内容超出当前默认范围时,会占用其他的组件的位置。如何让其自动进行滚动,而不影响其他组件的显示
RichEditor组件在内容超过显示界面时,不会自动滚动,会把下方的控件覆盖。
代码如下:
import promptAction from '@ohos.promptAction';
import router from '@ohos.router'; // 引入router
@Entry
@Component
struct Index {
  // private defaultTextStyle : boolean = false;
  controller: RichEditorController = new RichEditorController();
  options: RichEditorOptions = { controller: this.controller };
  newContext() {
    this.controller.addTextSpan("0123456789\n", {
      style: {
        fontColor: Color.Pink,
        fontSize: "32",
      },
      paragraphStyle: {
        textAlign: TextAlign.Start,
        leadingMargin: 16
      }
    })
    this.controller.addTextSpan("012345678901234567890123456789012345678901234567890123456789\n", {
      style: {},
      paragraphStyle: {
        textAlign: TextAlign.Start,
        leadingMargin: 16
      }
    })
  }
  build() {
    Column() {
      //标题栏
      Row() {
        Column() {
          Button() {
            Image($r('app.media.icon_back'))
              .width($r('app.float.icon_size'))
              .height($r('app.float.icon_size'))
          }
          .width($r('app.float.hgt_item'))
          .height($r('app.float.hgt_item'))
          .stateStyles({
            normal: { .backgroundColor($r('app.color.clr_major'))
            },
            pressed: { .backgroundColor($r('app.color.clr_button_bg'))
            },
          })
          .onClick(() => {
            router.back();
          })
        }
        .justifyContent(FlexAlign.Center)
        .width($r('app.float.hgt_item'))
        .height($r('app.float.hgt_caption'))
        Column() {
          Text('用户输入')
            .width('100%')
            .height($r('app.float.hgt_caption'))
            .fontSize($r('app.integer.font_caption'))
            .fontColor($r('app.color.start_main'))
            .fontWeight(FontWeight.Normal)
            .textAlign(TextAlign.Center)
        }
        .justifyContent(FlexAlign.Center)
        .flexShrink(1)
        Column()
          .justifyContent(FlexAlign.Center)
          .width($r('app.float.hgt_item'))
          .height($r('app.float.hgt_caption'))
      }
      .width('100%')
      .height($r('app.float.hgt_caption'))
      .backgroundColor($r('app.color.clr_major'))
      RichEditor(this.options)
        .width('100%')
        .clip(true)
        .flexGrow(1)
        .expandSafeArea([SafeAreaType.KEYBOARD])
        .onReady(() => {
          this.newContext()
        })
      Divider().strokeWidth(10).color($r('app.color.clr_background'))
      Button('复制内容')
        .width('80%')
        .height($r('app.float.hgt_item'))
        .onClick(() => {
          this.newContext()
        }) //Button
    }
    .height('100%')
    .width('100%')
    .backgroundColor($r('app.color.clr_background'))
  }
}
        HarmonyOS
      
        赞
        
 收藏 0
 回答 1
 
        待解决
        
相关问题
 如何在键盘弹出时仅调整指定UI组件的位置,而不影响整体布局 
2695浏览  • 1回复 待解决
音频播放时如何不影响其他的应用播放音乐? 
486浏览  • 0回复 待解决
HarmonyOS 如何让系统设置的显示大小不影响app的界面显示 
3243浏览  • 1回复 待解决
当用户滚动Web区域内容时,如何带动其他区域进行滚动? 
1035浏览  • 1回复 待解决
HarmonyOS目前button组件默认都是蓝色背景,是否支持其他样式的button组件 
3214浏览  • 1回复 待解决
HarmonyOS List组件滑动到顶部添加新的数据后,如何让List组件的滚动位置停留在添加数据之前的位置,而不是滚动到页面最顶部 
1237浏览  • 1回复 待解决
【List组件】点击列表的当前item,怎么让当前item图标显示,同时其他item里图标隐藏 
1598浏览  • 1回复 待解决
HarmonyOS 如何检测Scroll在滚动时,是否滚动到某个子组件的位置 
998浏览  • 1回复 待解决
如何设置子组件宽度让其不超过父组件的大小 
2254浏览  • 3回复 待解决
如何将某个组件的点击事件传递给其他组件 
3209浏览  • 1回复 待解决
HarmonyOS Scroll组件是否可以滚动到指定的子组件的位置 
1415浏览  • 1回复 待解决
web组件嵌套滚动在折叠屏展开后收起时其滚动位置会发生变化 
1158浏览  • 1回复 待解决
HarmonyOS  web组件不支持自动跳转其他app 
1165浏览  • 1回复 待解决
实现List组件中每一个ListItem中的子组件都可以拖动而不被其他组件覆盖 
2340浏览  • 1回复 待解决
如何设置组件的尺寸范围? 
1209浏览  • 1回复 待解决
如何在Tabs中的tabBar,添加其他组件 
1886浏览  • 1回复 待解决
HarmonyOS 气泡内容过多超出屏幕范围时,固定气泡大小内部支持滑动显示 
776浏览  • 1回复 待解决
HarmonyOS Tabs组件使用中,如果tab比较多,滚动时,如何让选中的当前tab自动滚蛋到页面中间展示 
780浏览  • 1回复 待解决
HarmonyOS 使用相对布局如何让组件不超出页面 
879浏览  • 1回复 待解决
HarmonyOS 使用Grid组件开发可编辑顺序的功能,在拖拽item时如何设置其他组件顺序改变的动画效果 
1142浏览  • 1回复 待解决
HarmonyOS  子组件超过父组件的范围 
1172浏览  • 1回复 待解决
#鸿蒙学习大百科#如何监听RichEditor组件选中内容时的回调? 
1262浏览  • 1回复 待解决
HarmonyOS使用Web组件如何监听滚动位置 
1511浏览  • 2回复 待解决
HarmonyOS  Text组件获取当前显示的行数 
1182浏览  • 1回复 待解决
innodb中,空的列会占用存储吗? 
3577浏览  • 1回复 待解决





















可将RichEditor放入滑动组件中: