Domanda

Is it possible to give a TextField in Titanium JS an "auto" height?

I'm using location services, which then fill a text field with the location data when a location is found. But it's always far too long and gets an ellipsis. I'd like the text field to scale in height to fit the text.

I've tried this but it doesn't work:

$.location.value = p.city + ", " + p.country;
$.location.height = Ti.UI.SIZE;
È stato utile?

Soluzione

Text field does not grow automatically.You have to use the textarea for that purpose

var win = Ti.UI.createWindow({
  backgroundColor: 'white'
});
var textArea = Ti.UI.createTextArea({
  borderWidth: 2,
  borderColor: '#bbb',
  borderRadius: 5,
  color: '#888',
  font: {fontSize:20, fontWeight:'bold'},
  keyboardType: Ti.UI.KEYBOARD_NUMBER_PAD,
  returnKeyType: Ti.UI.RETURNKEY_GO,
  textAlign: 'left',
  value: 'I am a textarea',
  height:Ti.UI.SIZE,
  top: 60,
  width: 300, 
});
win.add(textArea);
win.open()

Thanks

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top