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无法自适应高度
608浏览 • 1回复 待解决
HarmonyOS Text组件如何实现文字大小自适应?
976浏览 • 1回复 待解决
HarmonyOS Text自适应内容宽度和自动省略
130浏览 • 1回复 待解决
WebView加载网页无法自适应
609浏览 • 1回复 待解决
RelativeContainer 里面嵌套子组件 text ,如何基于 text 的内容自适应高度?
630浏览 • 1回复 待解决
HarmonyOS RichText 无法自适应高度、无法设置富文本内容字体样式
824浏览 • 1回复 待解决
HarmonyOS RichText自适应高度
183浏览 • 1回复 待解决
HarmonyOS 高度自适应
429浏览 • 1回复 待解决
HarmonyOS webview高度不能自适应
98浏览 • 1回复 待解决
HarmonyOS RichText能否自适应高度
190浏览 • 1回复 待解决
HarmonyOS Web高度自适应问题
978浏览 • 1回复 待解决
HarmonyOS popup宽度自适应
111浏览 • 1回复 待解决
HarmonyOS webview自适应屏幕
175浏览 • 1回复 待解决
HarmonyOS ui自适应问题
138浏览 • 1回复 待解决
HarmonyOS RelativeContainer 不能自适应宽高
585浏览 • 1回复 待解决
HarmonyOS List高度根据内容自适应
338浏览 • 1回复 待解决
HarmonyOS RelativeContainer宽高自适应问题
935浏览 • 1回复 待解决
HarmonyOS Grid高度根据内容自适应
264浏览 • 1回复 待解决
HarmonyOS Tabs组件,TabContent的高度无法自适应内容组件高度
607浏览 • 1回复 待解决
HarmonyOS web组件加载本地HTML字符串时无法自适应高度
327浏览 • 1回复 待解决
HarmonyOS 自定义弹窗中放Web组件, 弹窗高度不能自适应, Web高度不能自适应
87浏览 • 1回复 待解决
HarmonyOS 高度自适应的问题
529浏览 • 1回复 待解决
HarmonyOS GridItem自适应高度问题
562浏览 • 1回复 待解决
HarmonyOS RelativeContainer自适应高度相关
228浏览 • 1回复 待解决
HarmonyOS grid如何自适应宽度
287浏览 • 1回复 待解决
Row布局时若子组件不设置flexShrink则默认不会压缩子组件,即所有子组件主轴大小累加可超过容器主轴。可以对子组件设置layoutWeight(1)进行解决或者设置flexShrink来解决row中子组件超过row容器的情况。但是让子组件重新布局这种情况就会出现红框没有去除的问题,无法避免。目前想到解决方案是去除左右间距来实现想要的效果,参考示例: