2013-06-11 28 views
0

我在一個「LabeledTextView」組件裏面使用了一個TextView(基本上,一個TextView的標籤在處理佈局變化時從一邊移動到另一邊,語言)。我用這一個ListView裏面,這是發生:在一個ListView裏面的ListView橫向截斷

enter image description here

文本的最後一行被截斷水平。這可能是Android的TextView onMeasure()中的一個錯誤?

這個相同的「LabeledTextView」組件用於其他情況,並且工作完全正常,所以我認爲這與它和ListView之間的交互有關。

列表項XML的相應部分看起來像這樣:

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_weight="1" 
    android:layout_height="400dp" 
    android:orientation="vertical" > 

    <com.test.library.view.LabeledTextView 
     android:id="@+id/sender" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     custom:label="@string/sender" 
     custom:labelWidth="130dp"/>  

    <com.test.library.view.LabeledTextView 
     android:id="@+id/message" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     custom:label="@string/message" 
     custom:labelWidth="130dp"/>     

</LinearLayout> 

你可以看到,在含有的LinearLayout,我保證容器的高度不削減規模。

自定義視圖設置LayoutParams作爲WRAP_CONTENT的高度 - 你可以看到它的成長爲幾乎正確的尺寸。

編輯

手動然而,當增加LabeledTextView的大小,TextView正確地顯示,所以我想我的自定義視圖默認onMeasure()不正確佔TextView孩子的高度。

+0

您的linearLayout高度設置爲400dp,爲什麼不嘗試wrap_content? –

+0

我特別從wrap_content中增加了它,以確保容器不對此行爲負責。 – Graeme

回答

0

對於需要顯示答案的兩列使用不同的線性佈局。

即。一個爲發件人,一個爲消息