【问题标题】:Problems using a composite view in Titanium Alloy在钛合金中使用复合视图的问题
【发布时间】:2013-12-29 15:53:04
【问题描述】:

我正在尝试在 Alloy 中实现一个简单的应用程序,该应用程序具有非常基本的结构,但我无法可靠地对其进行布局。我正在尝试将一组导航按钮与它们上方的工作区域对齐,在下面的示例中将是一个 TableView。

<Alloy>
<Collection src="book">
<Window height="100%" id="main" title="My Library {opts.username}" exitOnClose="true" onOpen="loadExtras">
    <TableView id="content" dataCollection="book" top="10px" bottom="100px" onDragEnd="refreshTable">
        <TableViewRow title="{title}" color="black" onClick="showBook"/>
    </TableView>
    <View bottom="0px" height="72px" layout="horizontal" id="actionPanel">
        <Button class="footerBtn" onClick="refreshTable">View</Button>
        <Button class="footerBtn" onClick="refreshTable">Help</Button>
        <Button class="footerBtn" onClick="refreshTable">List</Button>
        <Button class="footerBtn add" onClick="addBook"></Button>   
    </View>
</Window>

我可以让它工作的唯一方法是为 TableView 指定一个高度,例如 height="80%" 然后使用这个值直到我喜欢的东西布局,但我不想像我那样做需要它独立于设备的物理屏幕尺寸工作。

我如何在 Alloy 中实现这种布局,以便将视图固定到屏幕底部,并在其上方有一个可变工作区域 - 或者,我是否必须假设一个标准高度并相对于该高度工作?

【问题讨论】:

    标签: titanium titanium-alloy


    【解决方案1】:

    尝试将表格固定到父视图的底部,然后将高度设置为父视图高度的 80%。另外,使用dp 值来独立于​​屏幕。

    <TableView id="content" height="80%" bottom="100dp" 
               onDragEnd="refreshTable"
               dataCollection="book">
    

    【讨论】:

    • 谢谢 - 这个问题原来是 app.tss 中的恶意声明,将所有 Window 元素设置为默认的垂直布局。在这种情况下,Alloy 会忽略任何绝对定位,这就是我无法将视图固定到底部的原因。当我将其更改为复合时,一切都按预期工作。
    猜你喜欢
    • 1970-01-01
    • 2014-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多