Skip to content

Instantly share code, notes, and snippets.

@lcruz
Created September 20, 2012 14:46
Show Gist options
  • Save lcruz/3756357 to your computer and use it in GitHub Desktop.
Save lcruz/3756357 to your computer and use it in GitHub Desktop.
Ejemplo de tabla con bordes redondeados y header con color en Android
function TableView() {
var self = Ti.UI.createView();
var data = [{title:"Row 1"},{title:"Row 2"}];
var table = createTable('Pagadores', self, data);
self.add(table);
return self;
}
function createTable(title, win, data) {
var top = 5;
var borderRadius = 15;
var width = 100;
var headerHeight = 30;
var borderColor = "#CCC";
var borderwidth = 1;
var backgroundColor = "#fff7a6";
var margin = 10;
var viewHeader = Ti.UI.createView({
top: top,
width: Titanium.Platform.displayCaps.platformWidth - (margin * 2),
height:headerHeight,
backgroundColor: backgroundColor,
borderRadius: borderRadius,
borderWidth: borderwidth,
borderColor: borderColor,
zIndex: 20,
left : margin,
right: margin
});
var viewBackground = Ti.UI.createView({
top: top + headerHeight -borderRadius + borderwidth,
height: borderRadius,
width: Titanium.Platform.displayCaps.platformWidth - (margin * 2),
backgroundColor : borderColor,
zIndex: 25
});
var view = Ti.UI.createView({
top: top + headerHeight - borderRadius,
height: borderRadius,
width: Titanium.Platform.displayCaps.platformWidth - (borderwidth * 2) - (margin * 2),
backgroundColor : backgroundColor,
zIndex: 30
});
var label = Titanium.UI.createLabel({
text:'Titulo',
height:'auto',
width:'auto',
shadowColor:'#aaa',
shadowOffset:{x:5,y:5},
color:'#000',
font:{fontSize:12},
textAlign:'center',
top: top + (headerHeight/2) - 6,
zIndex: 40
});
win.add(viewHeader);
win.add(viewBackground);
win.add(view);
win.add(label);
var row = Ti.UI.createTableViewRow({
height: borderRadius,
backgroundColor : borderColor
});
data.unshift(row);
var table = Ti.UI.createTableView({
top: top + headerHeight - (borderRadius * 1),
borderRadius: borderRadius,
borderColor: borderColor,
borderWidth: borderwidth,
separatorColor: borderColor,
zIndex: 10,
data : data,
left: margin,
right: margin
});
return table;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment