Flex中rowSpan的奇怪行为
时间:2020-03-05 18:44:28 来源:igfitidea点击:
在flex中使用Grid组件时,我遇到一些奇怪的事情,我具有以下形式,该形式使用网格来对齐字段,如我们所见,每个GridRow都有一个边框。
我的问题是,边框仍然可以通过跨越多行的GridItems看到(观察跨越4行的TextArea,GridRow边框向右扔掉!)
关于如何解决此问题的任何想法?
解决方案
回答
我认为问题在于绘制网格时,它是从上到下绘制每一行,并且在每一行中是从左到右的项目。因此,首先绘制跨行的<mx:TextArea>项,然后向下延伸到接下来的2行的区域中,该行在顶部和底部绘制。
我能看到的最快的方法是改为在<mx:GridItem>上绘制行边框,根据项目在行中的位置跳过左边缘和右边缘。像这样的东西:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Style> Grid { background-color: white; horizontal-gap: 0; } GridItem { padding-top: 5; padding-left: 5; padding-right: 5; padding-bottom: 5; background-color: #efefef; border-style: solid; border-thickness: 1; border-color: black; } .left { border-sides: top, bottom, left; } .right { border-sides: top, bottom, right; } .center { border-sides: top, bottom; } </mx:Style> <mx:Grid> <mx:GridRow> <mx:GridItem styleName="left"> <mx:Label text="Label"/> </mx:GridItem> <mx:GridItem styleName="center"> <mx:ComboBox/> </mx:GridItem> <mx:GridItem styleName="center"> <mx:Label text="Label"/> </mx:GridItem> <mx:GridItem styleName="right"> <mx:ComboBox/> </mx:GridItem> </mx:GridRow> <mx:GridRow> <mx:GridItem styleName="left"> <mx:Label text="Label"/> </mx:GridItem> <mx:GridItem styleName="center"> <mx:TextInput/> </mx:GridItem> <mx:GridItem colSpan="2" rowSpan="3"> <mx:VBox width="100%" height="100%"> <mx:Label text="Label"/> <mx:TextArea width="100%" height="100%"/> </mx:VBox> </mx:GridItem> </mx:GridRow> <mx:GridRow> <mx:GridItem styleName="left"> <mx:Label text="Label"/> </mx:GridItem> <mx:GridItem styleName="center"> <mx:TextInput/> </mx:GridItem> </mx:GridRow> <mx:GridRow> <mx:GridItem styleName="left"> <mx:Label text="Label"/> </mx:GridItem> <mx:GridItem styleName="center"> <mx:TextInput/> </mx:GridItem> </mx:GridRow> </mx:Grid> </mx:Application>