2011-12-15 34 views
0

我想要一個包含3個文本視圖的線性佈局。
文本1:ABCDEFGHIJKLMN
文本2: -
文本3:nmlkjihgfedcba3 TextView的ellipsize =「middle」

它應該看起來像:

/-----------------------\ 
| abc...lmn - nml...cba | 
\-----------------------/ 

當文本1較短, 「ABC」,那麼就應該是這樣的:

/-----------------------\ 
| abc - nmlkji...fedcba | 
\-----------------------/ 

我無法讓它工作。使用重量,但是「 - 」始終保持在中間。
有什麼想法?

+0

見我目前(最好)代碼:pastebin.com/UAmGq5if爲完整的代碼,並imagepaste.nullnetwork.net/viewimage.php?id=2934的圖像。但仍然不起作用,這裏第一個不是橢圓形的 – Tom 2011-12-15 22:49:43

回答

0

這應該工作。 weight正是你不應該在這裏使用的東西。除非我在這裏丟失了一些明顯的東西

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="abcdefghijklmn"/> 
    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="2dp" 
    android:layout_marginRight="2dp" 
    android:text="-"/> 
    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="nmlkjihgfedcba"/> 
</LinearLayout> 
+0

這不符合我的要求,因爲它會包裝文本。至少我需要使用ellipsize =「middle」。 有關完整的代碼,請參見:http://pastebin.com/UAmGq5if,圖像爲http://imagepaste.nullnetwork.net/viewimage.php?id=2934 – Tom 2011-12-15 16:52:51