2014-09-06 38 views
0

我有兩列的TableLayout。如果TextView中的文本比屏幕大小稍長(6或7個符號),則6或7個符號不可見。如果文字更長,更多符號可見。它是ListView的一部分,我在ImageView中動態加載文本內容和圖像。我希望TextView中的文本始終可見,不管它多長時間。我能做什麼?Android桌面:ImageView和TextView不可見長文本

這裏是我的佈局XML內容:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    > 

<TableLayout 
    android:id="@+id/message_table_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:stretchColumns="1" 
    > 
<TableRow> 
<ImageView 
    android:id="@+id/message_image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical" 
/> 
<TextView 
    android:id="@+id/message_title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Technical Support Representative" 
    android:layout_below="@+id/message_image" 
    android:layout_gravity="center_vertical" 
/> 
</TableRow> 
</TableLayout> 
</RelativeLayout> 

這是我的文字:

String messageTitleText = "<b> Xxxxxxx xxx xxx xx<br/> Xxxxxxxxxx<br/> Xxxxxxxxxxx<br/> xxxxxxxxxxxxxxxx<br/> xxx xxxxxxxxx x xxxxxxxx xx 1234567890<br/> xxxxxxx xxxx<br/> xxxxxxx xxxx xxxx"; 
    messageTitle.setText(Html.fromHtml(messageTitleText)); 

我的HTC 「1234」 後,不顯示字符, 「567890」 被隱藏。

感謝

回答

0

試試這個

<TextView 
    android:id="@+id/message_title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:maxLines="4" 
    android:lines="4" 
    android:text="Technical Support Representative" 
    android:layout_below="@+id/message_image" 
    android:layout_gravity="center_vertical" 
/> 
+0

謝謝,這不生效。 TextView中的文本是多行的,只能更改可見行數。 – user3054412 2014-09-06 18:34:46

+0

嘗試在android:text =「技術支持代表」中添加更多文本,您將看到結果,例如技術支持代表,技術支持代表,技術支持代表,技術支持代表,技術支持代表,技術支持代表,技術支持代表,技術支持代表。 ...「' – 2014-09-06 18:35:51

+0

在文章中添加我的測試文本。你看見了嗎? – user3054412 2014-09-06 18:39:26

0

現在我用這一點,這是確定:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" > 

<ImageView 
    android:id="@+id/message_image" 
    android:layout_gravity="center" 
    android:layout_width="120px" 
    android:layout_height="48dp" 
    android:src="@drawable/ic_launcher" /> 

<TextView 
    android:id="@+id/message_title" 
    android:layout_gravity="center" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="TextView" /> 

</LinearLayout>