当单击合金按钮时,标签文本在按钮上消失

时间:2015-12-06 13:18:10

标签: button label titanium

开发。 请帮我。 我正在使用Titanium SDK开发应用程序。 我遇到了自己无法解决的问题。 单击按钮时,标签文本有时会消失。

我将在这里添加.xml和.tss代码。 ---------------。tss文件------------------

".container": {
    backgroundColor:"white"
}
"#select_language_pannel": {
    width: '84%',
    height: '45%',  
    image: '/images/select_language_pannel.png'
}

"#register_label":{
    top: '20%',
    text: 'Register New User',
    color : '#008c99',
    width: '100%',
    textAlign: 'center',
    font: {fontSize: '18dp', fontWeight:"bold"}
}

"#investor_button": {
    layout: 'vertical',
    top: '40%',
    width: '64%',
    height: '13%',
    backgroundImage : '/images/btn_login_common_normal.png',
    backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}

"#investor_text": {
    text: 'INVESTOR',
    height: '100%',
    color: '#008c99',
    highlightedColor: '#FFFFFF'
}

"#company_button": {
    layout: 'vertical',
    top: '60%',
    width: '64%',
    height: '13%',
    backgroundImage : '/images/btn_login_common_normal.png',
    backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}

"#company_text": {
    text: 'COMPANY',
    color: '#008c99',
    height: '100%',
    highlightedColor: '#FFFFFF'
}

-----------------。xml文件---------------

<Alloy>
    <Window class="container">
        <ImageView image="/images/selectlanguage_bg.png">
            <ImageView id="select_language_pannel">
                <Label id = "register_label"></Label>
                <Button id = "investor_button" onClick="onClickInvestor">
                    <Label id = "investor_text"></Label>
                </Button>
                <Button id = "company_button" onClick="onClickCompany">
                    <Label id = "company_text"></Label>
                </Button>
            </ImageView>
        </ImageView>

    </Window>
</Alloy>

2 个答案:

答案 0 :(得分:0)

按钮不能有嵌套标签。相反,您应该使用按钮的title属性来显示文本。

<Button id = "company_button" onClick="onClickCompany" />

并且tss:

"#company_button": {
    layout: 'vertical',
    top: '60%',
    width: '64%',
    height: '13%',
    backgroundImage : '/images/btn_login_common_normal.png',
    backgroundSelectedImage: '/images/btn_login_common_pressed.png',
    title: "COMPANY",
    color: '#008c99'
}

答案 1 :(得分:0)

"#company_button": {
    layout: 'vertical',
    top: '60%',
    width: '64%',
    height: '13%',
    backgroundImage : '/images/btn_login_common_normal.png',
    backgroundSelectedImage: '/images/btn_login_common_pressed.png',
    title: "COMPANY",
    color: '#008c99',
    style:Ti.UI.iPhone.SystemButtonStyle.PLAIN
}
  

style:Ti.UI.iPhone.SystemButtonStyle.PLAIN

将此添加到按钮样式并给出标题希望它可以正常工作!