titanium - 查看钛金属 TSS

标签 titanium titanium-mobile titanium-alloy

您好,我是钛合金新手,不知道如何使用 TSS 创建流体设计。如何放置三个 View ,一个作为页眉 (20%),两个作为内容支架 (60%),三个作为页脚 (20%),全宽 (Ti.UI.FILL)。我的代码是,

index.xml

<Alloy>
   <Window class="container">
       <Require src="home" id="home"></Require>
   </Window>
</Alloy>

home.xml

<Alloy>
    <View id="header"></View>
    <View id="content"></View>
    <View id="footer"></View>
</Alloy>

home.tss

"#home": {
    layout: 'vertical',
    width: Ti.UI.FILL,
    height: Ti.UI.FILL,
    backgroundColor: '#000'
},
'#header':{
    layout: 'horizontal',
    height: '20%',
    width: Ti.UI.FILL,
    backgroundColor: '#fff'
},
'#content': {
    layout: 'vertical',
    height: '60%',
    width: Ti.UI.FILL,
    backgroundColor: '#ccc'
},
'#footer': {
    layout: 'horizontal',
    height: '20%',
    width: Ti.UI.FILL,
    backgroundColor: '#fff'
}

我尝试的是将后退按钮(左)、标题(中)和刷新按钮(右)作为水平布局放置在标题 View 中,并将应用内容放置在内容 View <中/strong> 并在页脚 View 中进行一些滚动选择(即,我们可以通过在其上放置选项来使用幻灯片事件进行滚动)。如果我运行此代码, View 最终会被划分为 this 60% 的人的内容 View 不受影响。我已经在 appcelerator 论坛中询问过,但尚未得到答复。希望这会有所帮助。

最佳答案

您的 id 为“home”的对象实际上并不是一个 View ,它只是对 home 类的引用,因此您不能像这样将样式归因于它。

我会像这样重新放置 home.xml:

<Alloy>
    <View id="homeHolder">
        <View id="header"></View>
        <View id="content"></View>
        <View id="footer"></View>
    </View>
</Alloy>

然后这就会像你期望的那样工作

"#homeHolder": {
    layout: 'vertical',
    width: Ti.UI.FILL,
    height: Ti.UI.FILL,
    backgroundColor: '#000'
}

关于titanium - 查看钛金属 TSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19096316/

相关文章:

android - 在 Titanium Android 中调整选项卡组标题高度

titanium - 在钛合金中调用函数或定位另一个 Controller 中的元素

java - 解析钛合金中的xml

android - 如何对齐 Ti.UI.Toolbar 项目? (安卓应用加速器)

javascript - Titanium Appcelerator 打开新窗口和上一个标题的动态后退按钮

Controller 销毁后触发钛应用程序事件

ios - 从使用 Titanium Appcelerator 创建的应用程序中删除灰色调

javascript - 在 Titanium 中将 View 创建为弹出窗口

android - 测试人们在钛中静止或运动

titanium - 在 tableviewrow 钛合金中获取事件点击