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组件的位置,而不影响整体布局
2059浏览 • 1回复 待解决
HarmonyOS 如何让系统设置的显示大小不影响app的界面显示
1147浏览 • 1回复 待解决
当用户滚动Web区域内容时,如何带动其他区域进行滚动?
471浏览 • 1回复 待解决
HarmonyOS目前button组件默认都是蓝色背景,是否支持其他样式的button组件
2328浏览 • 1回复 待解决
【List组件】点击列表的当前item,怎么让当前item图标显示,同时其他item里图标隐藏
1071浏览 • 1回复 待解决
HarmonyOS 如何检测Scroll在滚动时,是否滚动到某个子组件的位置
203浏览 • 1回复 待解决
如何设置子组件宽度让其不超过父组件的大小
1468浏览 • 2回复 待解决
如何将某个组件的点击事件传递给其他组件
2429浏览 • 1回复 待解决
HarmonyOS web组件不支持自动跳转其他app
465浏览 • 1回复 待解决
web组件嵌套滚动在折叠屏展开后收起时其滚动位置会发生变化
514浏览 • 1回复 待解决
HarmonyOS Scroll组件是否可以滚动到指定的子组件的位置
208浏览 • 1回复 待解决
如何在Tabs中的tabBar,添加其他组件
1071浏览 • 1回复 待解决
实现List组件中每一个ListItem中的子组件都可以拖动而不被其他组件覆盖
1284浏览 • 1回复 待解决
HarmonyOS 气泡内容过多超出屏幕范围时,固定气泡大小内部支持滑动显示
175浏览 • 1回复 待解决
HarmonyOS Tabs组件使用中,如果tab比较多,滚动时,如何让选中的当前tab自动滚蛋到页面中间展示
232浏览 • 1回复 待解决
如何设置组件的尺寸范围?
660浏览 • 1回复 待解决
HarmonyOS 使用相对布局如何让组件不超出页面
243浏览 • 1回复 待解决
#鸿蒙学习大百科#如何监听RichEditor组件选中内容时的回调?
515浏览 • 1回复 待解决
HarmonyOS 子组件超过父组件的范围
392浏览 • 1回复 待解决
HarmonyOS 使用Grid组件开发可编辑顺序的功能,在拖拽item时如何设置其他组件顺序改变的动画效果
482浏览 • 1回复 待解决
HarmonyOS List组件,单行横向排列,怎么让内容展示不全的项不显示?
294浏览 • 1回复 待解决
HarmonyOS Tab组件的顶部Tab栏,在设置为可滚动时,无法手动控制滚动位置
833浏览 • 1回复 待解决
HarmonyOS Text组件获取当前显示的行数
294浏览 • 1回复 待解决
HarmonyOS使用Web组件如何监听滚动位置
873浏览 • 2回复 待解决
可将RichEditor放入滑动组件中: