4 Replies Latest reply on Dec 1, 2011 3:23 AM by Tink Ltd

    Flex Hero - How to center view title

    ghess01

      Hi All,

       

      Cant seem to figure out how to center a view title.

       

      How should we do this, is it possible to do it in the Mobile application so all views have a centered tile?

       

      Tried setting the titleLayou to HorizontalLayout with horizontalAlign='center' and verticalAlign='middle' with no success.

       

      Any help much appreciated.


      Greg

        • 1. Re: Flex Hero - How to center view title
          Brandon Ellis Level 1

          Hi,

          Did you try setting textAlign="center" ?

           

              <s:titleContent>
                  <s:Label text="My View" textAlign="center" width="100%" />
              </s:titleContent>

          • 2. Re: Flex Hero - How to center view title
            ghess01 Level 1

            Thanks Brandon,

             

            That works, I wanted to center the title to the center of the ActionBar, not the titleGroup.

             

            I was able to achieve it using your strategy by setting the Labels width to (appWidth - (navigationGroup.width*2)) and textAlign="center".

             

            To be honest, not sure if it is a good idea as it may cause issues with  truncated text, overlapping navigation/action buttons. Trying to match  the UI design... and it has centered title... I will test more...

             

            When I do add my own label as to the titleContent I lose my styling. I have been avoiding setting font sizes and such as I want to leverage default font sizes specified in the "mobileTheme".

             

            Do you know how I can access these "mobileTheme" various font sizes so I can match custom components with ones from Flex SDK?

             

            Thanks,

             

            Greg

            • 3. Re: Flex Hero - How to center view title
              Brandon Ellis Level 1

              Hey Greg,

              I took a look under the hood and it appears to center the title property of the actionBar you are going to need to make a custom ViewNavigator and then add some custom skinparts inside of that. It sounds like a lot but it's not really. I'd help you out more if I wasn't so busy with my own work.

               

              hope that helps you out.

              b

              • 4. Re: Flex Hero - How to center view title
                Tink Ltd

                 

                s|ActionBar

                 

                {

                     titleAlign : center;

                }