钛合金移动合金:分数视图大小* .tss或* .xml

时间:2014-06-28 15:31:43

标签: titanium titanium-mobile titanium-alloy

我的容器里面有七个视图:

<View class="container>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
</View>

是否可以在不使用postlayout事件的情况下将按钮的宽度设置为* .tss或* .xml中容器宽度的1/7?有了四个视图,我只需指定25%,但使用14.285714285%七个视图宽度总和会超过100%。

1 个答案:

答案 0 :(得分:0)

它超过100%的原因是因为floating point math is funky。另外,为了复合这一点,我认为Titanium会将这些百分比用于代码(只是推测)。

为简单起见,请尝试将百分比保持为整数,如下所示:

".day" : {
    width : "14%"
}

<View class="container" layout="horizontal">
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
    <Button class="day"/>
</View>

你可能能够逃脱&#34; 14.2%&#34;同样,因为它没有那么多有效数字。