HarmonyOS Text无法自适应
@Entry
@Component
struct TestPage {
commentsList: CommentList[] = []
build() {
List() {
ForEach(this.commentsList, (item: CommentList, index: number) => {
ListItem() {
Row() {
Image($r('app.media.head'))
.alt($r('app.media.head'))
.height(20).width(20)
.margin(8)
Text() {
Span(item.name + ':')
.fontColor($r('app.color.AAAAAA'))
.fontSize('14fp')
Span(item.content)
.fontColor($r('app.color.333333'))
.fontSize('14fp')
}
.margin({ top: 10, bottom: 10, right: 12 })
}
.margin({
top: 5,
bottom: 5,
left: 20,
right: 20
})
.borderRadius(4)
.backgroundColor($r('app.color.F5F5F5'))
}
})
}
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
.margin({ top: 50 })
}
aboutToAppear(): void {
this.commentsList.push(new CommentList('111', 'xxx'))
this.commentsList.push(new CommentList('222', 'xxx'))
this.commentsList.push(new CommentList('333', 'xxx'))
this.commentsList.push(new CommentList('555', 'xxx'))
}
}
@Observed
export class CommentList {
name: string
content: string
constructor(name: string, content: string) {
this.name = name
this.content = content
}
}
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
HarmonyOS RelativeContainer无法自适应高度
1512浏览 • 1回复 待解决
HarmonyOS Text组件如何实现文字大小自适应?
2105浏览 • 1回复 待解决
HarmonyOS Text自适应内容宽度和自动省略
1118浏览 • 1回复 待解决
WebView加载网页无法自适应
1610浏览 • 1回复 待解决
RelativeContainer 里面嵌套子组件 text ,如何基于 text 的内容自适应高度?
1432浏览 • 1回复 待解决
HarmonyOS RichText 无法自适应高度、无法设置富文本内容字体样式
1711浏览 • 1回复 待解决
HarmonyOS RichText自适应高度
1048浏览 • 1回复 待解决
HarmonyOS 高度自适应
1335浏览 • 1回复 待解决
HarmonyOS webview高度不能自适应
984浏览 • 1回复 待解决
HarmonyOS RichText能否自适应高度
818浏览 • 1回复 待解决
HarmonyOS Web高度自适应问题
1988浏览 • 1回复 待解决
HarmonyOS Tabs组件,TabContent的高度无法自适应内容组件高度
1377浏览 • 1回复 待解决
HarmonyOS ui自适应问题
937浏览 • 1回复 待解决
HarmonyOS popup宽度自适应
915浏览 • 1回复 待解决
HarmonyOS webview自适应屏幕
1116浏览 • 1回复 待解决
HarmonyOS web组件加载本地HTML字符串时无法自适应高度
1227浏览 • 1回复 待解决
HarmonyOS RelativeContainer 不能自适应宽高
1346浏览 • 1回复 待解决
HarmonyOS RelativeContainer宽高自适应问题
2117浏览 • 1回复 待解决
HarmonyOS List高度根据内容自适应
1288浏览 • 1回复 待解决
HarmonyOS Grid高度根据内容自适应
1072浏览 • 1回复 待解决
HarmonyOS 自定义弹窗中放Web组件, 弹窗高度不能自适应, Web高度不能自适应
909浏览 • 1回复 待解决
HarmonyOS grid如何自适应宽度
1088浏览 • 1回复 待解决
HarmonyOS webview如何设置自适应
1671浏览 • 1回复 待解决
HarmonyOS 高度自适应的问题
1323浏览 • 1回复 待解决
HarmonyOS RelativeContainer自适应高度相关
1043浏览 • 1回复 待解决
Row布局时若子组件不设置flexShrink则默认不会压缩子组件,即所有子组件主轴大小累加可超过容器主轴。可以对子组件设置layoutWeight(1)进行解决或者设置flexShrink来解决row中子组件超过row容器的情况。但是让子组件重新布局这种情况就会出现红框没有去除的问题,无法避免。目前想到解决方案是去除左右间距来实现想要的效果,参考示例: