自叹不如尽可能多的行 - 我在代码中创建了我的TextView,并且它包装 - 尽管我没有设置任何东西,除了标准的东西 - 但请亲自看看:
LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
childParams.setMargins(5, 5, 5, 5);
Label label = new Label(this);
label.setText("This is a testing label This is a testing label This is a testing label This is a testing labelThis is a testing label This is a testing label");
label.setLayoutParams(childParams);
正如您从参数定义中可以看到的,我使用的是LinearLayout。类Label只是简单地扩展了TextView - 除了设置字体大小和字体颜色外,没有做任何事情。
在仿真器(API级别9)中运行它时,会自动将文本换行为3行。
默认情况下,TextView应该自动换行。你可以发布你的整个布局? – danh32 2011-01-31 16:28:29
任何机会是表格布局中的Textview?如果有的话,我为你解答。 – JohnFx 2011-02-22 00:55:13