Flex(用于移动应用程序)是否可以呈现具有透明背景的列表项?
我的应用程序设计包含一个应该保持可见的背景。
我尝试将 contentBackgroundAlpha 设置为 0,但这不会影响项目渲染器。另外,我尝试过 alterItemColors="[0xffffffff, 0xffffffff]",但它们仍然不透明。
还有其他解决方法吗?这甚至可能吗?
谢谢。
Flex(用于移动应用程序)是否可以呈现具有透明背景的列表项?
我的应用程序设计包含一个应该保持可见的背景。
我尝试将 contentBackgroundAlpha 设置为 0,但这不会影响项目渲染器。另外,我尝试过 alterItemColors="[0xffffffff, 0xffffffff]",但它们仍然不透明。
还有其他解决方法吗?这甚至可能吗?
谢谢。
这是我的实现:
1)将此添加到您的自定义 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)将此添加到您的列表属性:
contentBackgroundAlpha="0.5"
alpha="0.5"
我认为您正在寻找的财产:
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>