【问题标题】:Flex for mobile: Is it possible to make list items transparents?Flex for mobile:是否可以使列表项透明化?
【发布时间】:2012-03-12 22:54:14
【问题描述】:

是否可以在 Flex(用于移动应用程序)中呈现具有透明背景的列表项?

我的应用设计包含应保持可见的背景。

我尝试将 contentBackgroundAlpha 设置为 0,但这不会影响项目渲染器。另外,我尝试了 alterItemColors="[0xffffffff, 0xffffffff]",但它们仍然不透明。

还有其他解决方法吗?这可能吗?

谢谢。

【问题讨论】:

    标签: actionscript-3 apache-flex flex4.5 itemrenderer flex-mobile


    【解决方案1】:

    我认为您正在寻找该物业: 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>
    

    【讨论】:

      【解决方案2】:

      这是我的实现:

      1) 将此添加到您的自定义 IconItemRenderer for List:

      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"
      

      【讨论】:

        猜你喜欢
        • 2017-08-10
        • 1970-01-01
        • 2011-03-14
        • 1970-01-01
        • 2011-09-10
        • 1970-01-01
        • 2021-12-31
        • 1970-01-01
        相关资源
        最近更新 更多