29
Oct
07

Indenting Flex Accordion header labels

A recent comment asked how you can indent the Accordion header text as setting the paddingLeft style wasn’t working as expected for them. Well, as it turns out, you need to set the paddingLeft style directly on the AccordionHeader style (Flex 2 and 3) or create a new style with paddingLeft style specified and use the headerStyleName style (Flex 3 only).

Full code after the jump.

The following example works in Flex 2 and Flex 3:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/29/indenting-flex-accordion-header-labels/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        AccordionHeader {
            paddingLeft: 130; /* pixels */
        }
    </mx:Style>

    <mx:Accordion id="accordion"
            width="100%"
            height="100%">
        <mx:VBox label="One" />
        <mx:VBox label="Two" />
        <mx:VBox label="Three" />
        <mx:VBox label="Four" />
    </mx:Accordion>

</mx:Application>

View source is enabled in the following example.

The following example works in Flex 3:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/29/indenting-flex-accordion-header-labels/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical">

    <mx:Style>
        .accHeader {
            paddingLeft: 130; /* pixels */
        }
    </mx:Style>

    <mx:Accordion headerStyleName="accHeader"
            width="100%"
            height="100%">
        <mx:VBox label="One" />
        <mx:VBox label="Two" />
        <mx:VBox label="Three" />
        <mx:VBox label="Four" />
    </mx:Accordion>

</mx:Application>

View source is enabled in the following example.


1 Response to “Indenting Flex Accordion header labels”


  1. 1 coco Oct 29th, 2007 at 6:09 pm

    hi,
    it looks so easy!Great!

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".