Button width:
This is not working, although according to the documentation it should:
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Button-object
var btExample = Ti.UI.createButton({
title:'Animate',
top: 100,
height: '60',
***width: 'auto'***
});
The button doesn't show up.
No error messages.
This does work:
var btExample = Ti.UI.createButton({
title:'Animate',
top: 100,
height: '60',
***width: '100'***
});
Titanium Developer 1.2.1
3 Answers
-
Same problem here with a View + Label:
var view_btn = Ti.UI.createView({width:'auto',height:40,top:0,backgroundImage:"button.png",name:"btn"}); var lbl_btn = Ti.UI.createLabel({ text:"test, height:'auto', width:'auto', color:'#FFF', font:{fontSize:15}, textAlign:'center', name:"lbl" }); view_btn.add(lbl_btn);
android looks fine, on iphone the view is only as wide as the label and centered
-
@Joacim:
height:60
not
height:'60'
-
@Dan Tamas: Does not change the fact that width: 'auto' on buttons still isn't working.
And OP's question is a year old…Example:
var win = Titanium.UI.createWindow({ backgroundColor:'#fff', fullscreen: false }); var b = Titanium.UI.createButton({top: 10, left: 10, width: 150, height: 30, title:' Download ',style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED}); var b2 = Titanium.UI.createButton({top: 100, left: 10, width: 'auto', height: 30, title:' Download ',style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED}); win.add(b); win.add(b2); win.open();
—-> Button 2 is just not showing up :(
Anyone has an idea how to fix this?
Thanks, Thomas