Cómo acoplar un menú de pie de página a abajo en Appcelerator Titanium?
-
09-10-2019 - |
Pregunta
¿Cómo coloco en la base de un menú de pie de página a la parte inferior de la pantalla en Android y iPhone en Appcelerator Titanium? Quiero mostrar 3 iconos en la parte inferior de la pantalla.
Solución
Titanium.UI.View conjunto inferior:. 0 para conseguir que atracar en el fondo
Otros consejos
Sí, usamos Ti.UI.Toolbar para esto. Vamos a ver este código de ejemplo:
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);
Titanium.UI.ToolBar para eso.
Si está utilizando Appcelerator Marco de aleación
El código en la vista XML
<Alloy>
<Window title="My Nice Title">
... ... ...
... ... ...
<View class="footer-menu"></View>
</Window>
</Alloy>
El código de TSS
".footer-menu": {
backgroundColor: 'red',
width: '100%',
height: 40,
bottom: 0
}
Esto empujará la vista a abajo. Aquí está una captura de pantalla.
La no utilización de la aleación? Es similar en JS también.
// 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);
Espero que esto es útil. Gracias!
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);
funciona en Android, pero todavía sé por qué no haga el botón no puede aparecer en iphone
Recuerde que las barras de herramientas no son compatibles para Android o Tablet.
Si desea establecer botones de la parte inferior de la pantalla, cree una vista, ponerlo en la parte inferior y luego distribuir los botones con posición relativa, teniendo en cuenta el ancho de la pantalla.
Este es un ejemplo:
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;
Hacer esto ... que se están posicionando los botones en la vista.
El primer botón (button1) comienza en "izquierda: 0" y tiene una anchura de 30% de la Vista. El segundo botón (botón 2) comienza después del primer botón de más de un espacio, y así sucesivamente ...
Y la altura de ellos es el mismo que el punto de vista de.