Android LayoutParams什么都不做
我对TextView中的Android LayoutParams有问题。我想在一个200度x 200度的框中显示一个文本。但什么都没有表现出来。代码如下:Android LayoutParams什么都不做,android,textview,layoutparams,Android,Textview,Layoutparams,我对TextView中的Android LayoutParams有问题。我想在一个200度x 200度的框中显示一个文本。但什么都没有表现出来。代码如下: tr = new TableRow(this); TextView phone = new TextView(this); phone.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); phone.setLines(20); phone.setText(Html.fromHtml("<
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));
tr=新表格行(此);
TextView电话=新的TextView(此);
phone.setInputType(InputType.TYPE\u TEXT\u FLAG\u MULTI\u LINE);
电话线(20);
phone.setText(Html.fromHtml(“Beschreibung
”);
append(poi.getDescription());
tr.addView(电话,新的ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200));
tr.setPadding(10,15,10,15);
v=新视图(本);
v、 setBackgroundColor(Color.rgb(51,51,51));
table.addView(tr,新的TableLayout.LayoutParams(
LayoutParams.WRAP_内容,
LayoutParams.WRAP_内容);
table.addView(v,新的TableLayout.LayoutParams)(
LayoutParams.WRAP_内容,
1));
而不是
new ViewGroup.LayoutParams(calculatePxs(200),calculatePxs(200)));
tr.setPadding(10, 15, 10, 15);
使用TableRow.LayoutParams
比如:
new TableRow.LayoutParams(calculatePxs(200),calculatePxs(200)));
tr.setPadding(10, 15, 10, 15);
好的,行了。但是当文本到达边界时,TextView确实会换行。你知道为什么吗?试试这个帖子: