从Flex 4(spark)ItemRenderer中删除默认样式

时间:2022-03-22 22:37:19

I'm trying to make a horizontal list of labels with a space in-between them (for use as part of a ticker tape).

我正在尝试制作一个水平的标签列表,它们之间有一个空格(用作自动收报机磁带的一部分)。

Labels outside of a list have a transparent background but as part of either the ItemRenderer or List, they get a white background. My assumption is that this is part of the default styling applied to a Spark ItemRenderer.

列表外的标签具有透明背景,但作为ItemRenderer或List的一部分,它们将获得白色背景。我的假设是,这是应用于Spark ItemRenderer的默认样式的一部分。

Question - Is there any way to totally get rid of all default visual stylings applied to an ItemRenderer?

问题 - 有没有办法完全摆脱应用于ItemRenderer的所有默认视觉样式?

protected var messages:ArrayCollection = new ArrayCollection( new Array("1", "2", "3", "etc") );

<s:List dataProvider="{messages}" itemRenderer="SimpleTextRenderer">
    <s:layout >
        <s:HorizontalLayout verticalAlign="middle" />
    </s:layout>
</s:List>

SimpleTextRenderer:

SimpleTextRenderer:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx" 
            autoDrawBackground="false" contentBackgroundAlpha="0" >

    <s:Label text="{data}" />   

</s:ItemRenderer>

1 个解决方案

#1


1  

You can implement your own custom item renderer, extending UIComponent (or Label) for instance and implementing IItemRenderer. It's actually quite easy, as explained here (you won't need to implement both of the given interfaces, as one implements the other).

您可以实现自己的自定义项呈示器,例如扩展UIComponent(或Label)并实现IItemRenderer。它实际上非常简单,如此处所述(您不需要实现两个给定的接口,因为一个实现另一个)。

This will allow you to get rid of styling and stuff, because you'll precisely manage how your component gets rendered through its validation cycle.

这将允许您摆脱样式和东西,因为您将精确管理组件在其验证周期中的呈现方式。

#1


1  

You can implement your own custom item renderer, extending UIComponent (or Label) for instance and implementing IItemRenderer. It's actually quite easy, as explained here (you won't need to implement both of the given interfaces, as one implements the other).

您可以实现自己的自定义项呈示器,例如扩展UIComponent(或Label)并实现IItemRenderer。它实际上非常简单,如此处所述(您不需要实现两个给定的接口,因为一个实现另一个)。

This will allow you to get rid of styling and stuff, because you'll precisely manage how your component gets rendered through its validation cycle.

这将允许您摆脱样式和东西,因为您将精确管理组件在其验证周期中的呈现方式。