0

I have a problem with Android LayoutParams in a TextView. I want to display a Text in a Box of the size 200 dip x 200 dip. But nothing is showing. THis is the Code:

tr = new TableRow(this);
TextView phone = new TextView(this);
phone.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
phone.setLines(20);
phone.setText(Html.fromHtml("<b>Beschreibung</b><br /><br />"));
phone.append(poi.getDescription());
tr.addView(phone,new ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200)));
        tr.setPadding(10, 15, 10, 15);

v = new View(this);
v.setBackgroundColor(Color.rgb(51, 51, 51));

table.addView(tr,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

table.addView(v,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                1));
Bene
  • 636
  • 1
  • 8
  • 24

1 Answers1

0

Instead of

new ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200)));
    tr.setPadding(10, 15, 10, 15);

use TableRow.LayoutParams

Like :

new TableRow.LayoutParams(calculatePxs(200),calculatePxs(200)));
tr.setPadding(10, 15, 10, 15);
Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
  • Okey that works. But the TextView does make line breaks, when the text reaches the border. Do you know why? – Bene Sep 19 '12 at 09:50
  • Try this post : http://stackoverflow.com/questions/4831529/android-single-line-textview-without-the-dots – Eldhose M Babu Sep 19 '12 at 09:56