开发者

Removing default styling from Flex 4 (spark) ItemRenderer

开发者 https://www.devze.com 2023-04-05 19:36 出处:网络
I\'m trying to make a horizontal list of labels with a space in-between them (for use as part of a ticker tape).

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.

Question - Is there any way 开发者_JAVA技巧to totally get rid of all default visual stylings applied to an 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:

<?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>


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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消