我有一些與TextView高度有關的關鍵問題。我想根據運行時設置的內容設置TextView的高度。這裏是我的XML代碼: -Android - 將高度設置爲TextView動態
<TextView android:id="@+id/tv"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>`
這裏是Java代碼來設置TextView的高度:
TextView tv = (TextView) findViewById(R.id.tv);
tv.invalidate();
int height_in_pixels = tv.getLineCount() * tv.getLineHeight();
tv.setHeight(height_in_pixels);
但問題是,它僅顯示1行,並沒有其餘線。
我試過這個,但它不起作用。 – RATTLESNAKE 2010-09-07 12:28:55
@RATTLESNAKE:然後問題在你的輸入:))。你能在你的問題上發佈你的截圖嗎? – Praveen 2010-09-07 12:45:13