Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android LayoutParams什么都不做_Android_Textview_Layoutparams - Fatal编程技术网

Android LayoutParams什么都不做

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("<

我对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("<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确实会换行。你知道为什么吗?试试这个帖子: