Flex(适用于移动应用)是否可以呈现具有透明背景的列表项?
我的应用设计包含一个应该保持可见的背景。
我已尝试将contentBackgroundAlpha设置为0,但这不会影响项呈示器。另外,我尝试过alternatingItemColors =“[0xffffffff,0xffffffff]”,但它们仍然是不透明的。
还有其他解决方法吗?这甚至可能吗?
感谢。
答案 0 :(得分:0)
我认为您正在寻找该物业:
contentBackgroundAlpha="0"
然后在你的ItemRenderer中:
override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
{
// transparent background for hit detection
graphics.beginFill(0xFFFFFF, 0);
graphics.lineStyle();
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
// turn off opaqueBackground since this renderer has some transparency
opaqueBackground = null;
if (selected || hovered) {
this.setStyle('color', 0x94734D);
}
}
]]>
</fx:Script>
答案 1 :(得分:0)
这是我的实施:
1)将此添加到List的自定义IconItemRenderer:
override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
{
if (itemIndex % 2 == 0)
{
graphics.beginFill(0xFFFFFF, 0);
graphics.lineStyle();
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
}
else
{
// transparent background for hit detection
graphics.beginFill(0x004f94, 0.1);
graphics.lineStyle();
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
}
opaqueBackground = null;
if (selected)
{
// transparent background for hit detection
graphics.beginFill(0x004f94, 0.2);
graphics.lineStyle();
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
}
}
2)将其添加到List属性中:
contentBackgroundAlpha="0.5"
alpha="0.5"