Column(){
Shape()
.margin({left:16,right:16})
.width('100%')
.height(0.5)
.backgroundColor($r('app.color.color_DCDCDC'))
}.height('100%')
这么设置会导致margin不生效,这种如何解决
Column(){
Shape()
.margin({left:16,right:16})
.width('100%')
.height(0.5)
.backgroundColor($r('app.color.color_DCDCDC'))
}.height('100%')
这么设置会导致margin不生效,这种如何解决
1 回答1.1k 阅读✓ 已解决
1 回答1.3k 阅读
1 回答1.2k 阅读
1 回答1.1k 阅读
1 回答1.1k 阅读
1 回答971 阅读
1 回答945 阅读
margin是设置外边距属性,在Column布局中width 100%布局是居中的,此时组件设置margin,导致抵消了没有直观的现象,就会以为margin失效了;padding是设置内边距属性,所以设置.padding({left:16,right:16})可以有明显的现象。
如果想要背影颜色一起生效,需要禁用width(‘100%’)属性