自嘆不如儘可能多的行 - 我在代碼中創建了我的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