title: android EditText not automatically wrapping text
body: <p>I have looked all over the place and there are a ton of similar questions on this site, but I haven't found one that works and I'm wondering what I'm doing wrong. I have an EditText that I have to add programatically, it typically has only one line of text but I need it to wrap if the text is longer than the width of the view.</p>
  
  <p>the only xml i am using is for the table layout the edit text is eventually added to</p>
  
  <pre><code>&lt;TableLayout
   android:id="@+id/LineItemLayout"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginBottom="25dp"
   android:stretchColumns="4"
   &gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>The edit text is the one in the 4th column but even when I removed the stretchColumns attribute it still wasn't working. (i was thinking maybe the stretching column was messing up the width and it couldn't calculate when to wrap)</p>
  
  <p>Here is the code that gets looped through for each row I add to the table, p is the EditText I cant get working properly. just a bit of explanation, the row contains an EditText for a number (this one is fine, i do not want it multiline), then two Buttons and a TextView, and then the last item is the EditText that stretches the rest of the width and should be wrapping text. i put them all here in case they are causing problems because at this point i have no idea what to try next.</p>
  
  <pre><code>final TableRow l = new TableRow(EnvelopeModify.this);
  
  TextView t = new TextView(EnvelopeModify.this);
  
  t.setText("$" + lineItems.get(x).getTotal() + ", " + lineItems.get(x).getQuantity() + " " + lineItems.get(x).getItemUnits() + "");
  t.setPadding(5, 5, 30, 5);
  
  EditText p = new EditText(EnvelopeModify.this);
  p.setText(lineItems.get(x).getProposalDesc());
  p.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
  p.setBackgroundResource(R.color.blueEditText);
  p.setMinLines(1);
  p.setHorizontallyScrolling(false);
  p.setImeOptions(EditorInfo.IME_ACTION_DONE);
  //TableLayout.LayoutParams tempParams = new TableLayout.LayoutParams(0,LayoutParams.WRAP_CONTENT,1f);
  //p.setLayoutParams(tempParams);
  
  EditText o = new EditText(EnvelopeModify.this);
  o.setText(lineItems.get(x)._order);
  o.setWidth(50);
  o.setInputType(InputType.TYPE_CLASS_NUMBER);
  
  Button d = new Button(EnvelopeModify.this);
  d.setText("Remove");
  Button e = new Button(EnvelopeModify.this);
  e.setText("Edit");
  
  l.addView(o);
  l.addView(d);
  l.addView(e);
  l.addView(t);
  l.addView(p);
  lineItemLayouts.add(l); // this is the tableLayout in the xml above
  </code></pre>
  
  <p>supposedly setHorizontallyScrolling(false) will allow wrapping but adding that just made things worse. Not only does the text not wrap, but the text that should be wrapping is not visible because the edittext is only showing the first part of the text (not scrolling). I can still hit enter and a new line will be created as expected but I cannot get any text to wrap.</p>