grid布局显示网格线(网格布局gridlayout)

grid布局显示网格线(网格布局gridlayout)Grid ForEach span style color rgba 0 0 255 1 this span gridItems item index gt span style color rgba 0 0 0 1 span

大家好,我是讯享网,很高兴认识大家。



Grid() {

讯享网


讯享网

讯享网 ForEach(</span><span style="color: rgba(0, 0, 255, 1)">this</span>.gridItems,(item,index)=&gt;<span style="color: rgba(0, 0, 0, 1)">{ GridItem(){ Text(item) } .height(</span>'30%'<span style="color: rgba(0, 0, 0, 1)">) .width(</span>'30%'<span style="color: rgba(0, 0, 0, 1)">) .margin(</span>10<span style="color: rgba(0, 0, 0, 1)">) .backgroundColor(Color.Red) }) } .rowsTemplate(</span>'1fr 1fr 1fr') <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 设置两行</span> .rowsGap(10) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 设置行间距为10</span> .columnsGap(20) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 设置列间距为20</span> .layoutDirection(GridDirection.Row) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 设置从左到右排列,排满一行再排下一行,只设置rowsTemplate属性,当内容超出Grid区域时,可水平滚动。</span> .height('50%')</pre> 

小讯
上一篇 2025-05-04 08:40
下一篇 2025-05-01 13:44

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/151243.html