Skip to content

Instantly share code, notes, and snippets.

@rvulpescu
Created March 15, 2011 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvulpescu/870605 to your computer and use it in GitHub Desktop.
Save rvulpescu/870605 to your computer and use it in GitHub Desktop.
Android TextField drawing broken when using % width inside a tab window
Ti.App.isiOS = function() {
// add iphone specific tests
return (Titanium.Platform.name == 'iPhone OS');
};
function getMainMenuTabGroup() {
// create tab group
var tabGroup = Titanium.UI.createTabGroup({id: 'tabGroup1'});
var win1 = Titanium.UI.createWindow({
title : 'Settings',
backgroundColor : '#fff',
url: 'lib/settings/menuWindow.js'
});
var tab1 = Titanium.UI.createTab({
id : 'tab1',
icon : 'images/settings.png',
title : 'Settings',
window : win1
});
tabGroup.addTab(tab1);
return tabGroup;
}
//open tab group
tabGroup = getMainMenuTabGroup();
tabGroup.open();
//
// create base UI tab and root window
//
var win = Titanium.UI.currentWindow;
var data = [];
var loginGroup = Ti.UI.createTableViewSection({
headerTitle : 'Login details'
});
var row = Ti.UI.createTableViewRow({
height : 50
});
textFieldUsername = Titanium.UI.createTextField({
value : '',
width : '90%',
top : 10,
left : 10,
hintText : 'Username'
});
row.add(textFieldUsername);
if (Ti.App.isiOS()) {
row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
}
loginGroup.add(row);
//data.push(row); //for testing without groups
row = Ti.UI.createTableViewRow({
height : 50
});
textFieldPwd = Titanium.UI.createTextField({
value : '',
width : '90%',
top : 10,
left : 10,
hintText : 'Password'
});
row.add(textFieldPwd);
if (Ti.App.isiOS()) {
row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
}
loginGroup.add(row);
//data.push(row);
data.push(loginGroup);
var companyGroup = Ti.UI.createTableViewSection({
headerTitle : 'Company'
});
row = Ti.UI.createTableViewRow({
height : 50
});
textFieldCompany = Titanium.UI.createTextField({
value : '',
width : '90%',
top : 10,
left : 10,
hintText : 'Company'
});
row.add(textFieldCompany);
if (Ti.App.isiOS()) {
row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
}
companyGroup.add(row);
data.push(companyGroup);
//data.push(row);
var tableView;
if (Ti.App.isiOS()) {
tableView = Ti.UI.createTableView({
data : data,
style : Titanium.UI.iPhone.TableViewStyle.GROUPED
});
} else {
tableView = Ti.UI.createTableView({
data : data
});
}
win.add(tableView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment