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

有帮助吗?

解决方案

我用了 钛。UI.View 并设置底部:0将其放到底部。

其他提示

是的,我们使用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);

利用 钛。UI.Toolbar 为了那个原因。

如果您正在使用AppCelerator 合金框架

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
}

这将把视图推到底部。这是屏幕截图。

enter image description here

不使用合金? 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);

希望这很有帮助。谢谢!

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上显示

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

如果要将按钮设置在屏幕底部,请创建视图,将其设置在底部,然后以相对位置分配按钮,考虑屏幕宽度。

这是一个例子:

    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)以“左:0”开始,宽度为30%的视图。第二个按钮(按钮2)在第一个按钮加一个空间之后开始,依此类推...

它们的高度与视图相同。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top