javascriptappceleratorjtextareaappcelerator-alloy

How to increase height of textArea dynamically upto 3 line height (Just like whatsApp message box) in titanium appcelerator?


I need to implement dynamic height of textarea that expects a user to type comment. I have seen the interaction of textArea like this on WhatsApp. The text area will be initially of 1 line height later on as the user enters the text it should increase. But the text area should not be increased more than 3 line height.


Solution

  • As of now, I used a workaround to achieve that.

    var _lines = textFieldValue.split(/\r\n|\r|\n/).length;
    if(_lines > 3 || textFieldValue.length > 90) {
    $.textAreaDescriptionId.height = "80dp";
    } else {
      $.textAreaDescriptionId.height = Titanium.UI.SIZE;
    }