Skip to content

Instantly share code, notes, and snippets.

@dasher
Created June 20, 2010 12:58
Show Gist options
  • Save dasher/445819 to your computer and use it in GitHub Desktop.
Save dasher/445819 to your computer and use it in GitHub Desktop.
function percentageToPixels(p,width) {
if (width == null) {
width = Titanium.Platform.displayCaps.platformWidth-2;
}
return new Number((width * (p/100))).toFixed(0);
}
//create data entry view
var entryView = Ti.UI.createView({
backgroundColor:'#0060AA',
width:percentageToPixels(100),
height:100,
top:5
});
var controlsView = Ti.UI.createView({
width:'auto',
height:50
});
var controlsViewSub = Ti.UI.createView({
width:'auto',
height:50
});
var b1 = Titanium.UI.createButton({
title:'Save',
width:percentageToPixels(25,entryView.width),
height:35,
right:0,
enabled:false
});
controlsView.add(b1);
var tf1 = Titanium.UI.createTextField({
width:percentageToPixels(70,entryView.width),
height:35,
left:0,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
autocorrect:false,
hintText:'Enter a note...'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment