钛控制器有一个我似乎无法控制的高度

时间:2014-08-28 15:36:53

标签: titanium appcelerator controllers tss

我为我想在Titanium应用程序中重用的按钮创建了一个控制器。我在我的一个窗口中使用createController并将其添加到窗口中。到现在为止还挺好。

然而,按钮似乎有一个高度的完整窗口,我找不到改变它的方法。我错过了什么?在我的文件下面:

view button.xml

<Alloy>
    <View id="generalButtonContainer">
        <View id="generalButton" class="generalButton" onClick="callback" >
            <Label class="generalButtonLabel" id="generalButtonLabel" />
            <ImageView class="generalButtonIcon" />
        </View>
    </View>
</Alloy>

button.tss

".generalButton": {
    height: 60,
    borderRadius: 2,
    backgroundColor: '#5ba7e6',
    left: 10,
    right: 10
}

".generalButtonLabel": {
    color: '#ffffff',
    font: {
        fontSize: 16
    },
    left: 15
}


".generalButtonIcon": {
    image: '/images/generic/arrow-thin-right-white.png',
    height: 15,
    width: 15,
    top: 22,
    right: 15
}
"#generalButtonContainer": {
    width: 320,
    height: Ti.UI.SIZE
}

在这里,我将它包含在我的父窗口中

Alloy.createController('button',{text: 'signup.button.continue'});
$.signupButtonContainer.add(buttonView.getView());

现在,即使我指定了一个高度(也在signupButtonContainer上的父窗口中:Ti.UI.SIZE),我仍然可以获得一个完整的窗口高度视图。

如何解决此问题?

编辑:如果您遗失任何信息,请询问!包含大量信息的复杂问题

1 个答案:

答案 0 :(得分:1)

我没有看到任何明显的东西。调试这些布局问题可能涉及一些试验和错误。我建议采用两种策略。

1)检查Resources / platform / alloy / controllers / controller .js中生成的代码,看看那里是否有明显的东西。请记住没有显式值的那些组件的各种布局组件的默认高度/宽度。

2)我建议您使用LiveView或TiShadow,以便快速查看布局更改。然后,开始将各种元素的背景颜色设置为明显的颜色(像粉红色,橙色,绿色等字符串一样好用),看看哪个正在填充屏幕。