简体   繁体   English

flex4如何设置Panel的标题样式?

[英]flex4 how to set style of a Panel's Title?

in flex4 how to set style of a Panel's title? 在flex4中如何设置Panel的标题样式? For example, how to set the title alignment to center? 例如,如何将标题对齐设置为居中? Any advice would help. 任何建议都会有帮助。 Thanks in advance. 提前致谢。

You just need to define a new skin for your panel and change the textAlign property in it. 您只需为面板定义一个新外观并更改其中的textAlign属性。

在此输入图像描述

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           minWidth="955" minHeight="600">

<s:Panel 
    width="200" height="150" 
    left="40" top="40" 
    title="This is my panel" 
    skinClass="assets.skins.MyPanelSkin"/>

</s:Application>

In your skin file you need to find this block: 在您的皮肤文件中,您需要找到此块:

    <!-- layer 3: text -->
    <!--- @copy spark.components.Panel#titleDisplay -->
    <s:Label id="titleDisplay" maxDisplayedLines="1"
    left="9" right="3" top="1" bottom="0" minHeight="30"
    verticalAlign="middle" textAlign="start" fontWeight="bold">
    </s:Label>

and change 并改变

textAlign="start"

to

textAlign="center"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM