尺寸大于toolbar高度的图片使用scale属性设置。参考代码如下:
@Entry
@Component
struct NavigationExample {
build() {
Column() {
Navigation() {
}.toolbarConfiguration(this.NavigationToolbar)
}
.height('100%')
.width('100%')
.backgroundColor(Color.Gray)
}
@Builder
NavigationToolbar() {
Row() {
Column() {
Image($r('app.media.icon')).width(24)
}.layoutWeight(1)
Column() {
Image($r('app.media.icon')).width(24).scale({ x: 2, y: 2 })
}.layoutWeight(1)
Column() {
Image($r('app.media.icon')).width(24)
}.layoutWeight(1)
}
.height(34)
.width('100%').backgroundColor(Color.White)
}
}