[英]Flex for mobile: Is it possible to make list items transparents?
Flex(針對移動應用)是否可以使用透明背景渲染列表項?
我的應用程序設計包含應保持可見的背景。
我嘗試將contentBackgroundAlpha設置為0,但這不會影響項目渲染器。 另外,我嘗試過alternatingItemColors =“ [0xffffffff,0xffffffff]”,但它們仍然不透明。
還有其他解決方法嗎? 那有可能嗎?
謝謝。
我認為您正在尋找屬性: 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)將此添加到您的自定義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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.