0

如何在 Appcelerator Titanium 中将页脚菜单停靠在 Android 和 iPhone 的屏幕底部?我想在屏幕底部显示 3 个图标。

4

6 回答 6

4

我使用Titanium.UI.View并设置了 bottom: 0 让它停靠在底部。

于 2010-10-20T17:31:24.450 回答
3

是的,我们为此使用 Ti.UI.Toolbar。让我们看看这个示例代码:

var space = Titanium.UI.createButton({
    systemButton: Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});

var buttonNextEnd = Titanium.UI.createButton({
    title: '>>'
});
var buttonNext1Page = Titanium.UI.createButton({
    title: '>'
});
var buttonPrevEnd = Titanium.UI.createButton({
    title: '<<'
});
var buttonPrev1Page = Titanium.UI.createButton({
    title: '<'
});

var toolbarNav = Titanium.UI.createToolbar({
    left : 0,
    bottom: 0,
    height : 40,
    width : 320,
    items: [buttonPrevEnd,space, buttonPrev1Page,space, buttonNext1Page, space,buttonNextEnd]
});

win.add(toolbarNav);
于 2010-10-22T13:37:52.350 回答
2

为此使用Titanium.UI.ToolBar

于 2010-10-20T15:33:47.000 回答
1

如果您使用的是 Appcelerator Alloy 框架

XML 视图中的代码

<Alloy>
    <Window title="My Nice Title">
        ...   ...   ...
        ...   ...   ...
        <View class="footer-menu"></View>
    </Window>
</Alloy>

TSS 中的代码

".footer-menu": {
    backgroundColor: 'red',
    width: '100%',
    height: 40,
    bottom: 0
}

这会将视图推到底部。这是一个屏幕截图。

在此处输入图像描述

不使用合金?在 JS 中也是类似的。

// create window     
var win = Ti.UI.createWindow({
    // if anything
});
// create view
var footer_menu = Ti.UI.createView({
    backgroundColor: 'red',
    width: '100%',
    height: 40,
    bottom: 0
});
// add view to window
win.add(footer_menu);

希望这会有所帮助。谢谢!

于 2015-04-25T03:06:37.463 回答
0
var footer = Ti.UI.createView({

    height:25
});

var footerButton = Ti.UI.createLabel({

    title:'Add Row',
    color:'#191',
    left:125,
    width:'auto',
    height:'auto'
});

footer.add(footerButton);

它适用于android,但我仍然不知道为什么按钮不能出现在iphone上

于 2010-11-13T10:50:12.960 回答
0

请记住,工具栏与 Android 或平板电脑不兼容。

如果要将按钮设置在屏幕底部,请创建一个 View,将其设置在底部,然后根据屏幕宽度分配相对位置的按钮。

这是一个例子:

    function FirstWindow() {
    var self = Ti.UI.createWindow({
        background : "black",
        height : "auto",
        width : "auto",
        layout : "vertical"
    });

    teste = Ti.UI.createView({
        left : 0,
        bottom : 0,
        opacity : .7,
        backgroundColor : "#3d3d3d",
        height : 55
    });


    var button1 = Ti.UI.createButton({
                title : "button 1",
        left : 0,
        width : Titanium.Platform.displayCaps.platformWidth * 0.3
    });
    var button2 = Ti.UI.createButton({
                title : "button 2",
        left : Titanium.Platform.displayCaps.platformWidth * 0.33,
        width : Titanium.Platform.displayCaps.platformWidth * 0.3
    });
    var button3 = Ti.UI.createButton({
                title : "button 3",
        left : Titanium.Platform.displayCaps.platformWidth * 0.66,
        width : Titanium.Platform.displayCaps.platformWidth * 0.3
    });
    view.add(button1);
    view.add(button2);
    view.add(button3);

        self.add(view);

    return self;
}

module.exports = FirstWindow;

这样做...您将按钮定位在视图中。

第一个按钮 ( button1 ) 从 "left: 0" 开始,宽度为视图的 30%。第二个按钮( button2 )在第一个按钮加上一个空格之后开始,依此类推......

它们的高度与视图的高度相同。

于 2014-02-25T13:22:58.520 回答