2011-07-20 123 views
0

我希望三個按鈕間隔相等,大小相同。當其中一個按鈕的文本超過3個單詞(新行)時,按鈕會如圖所示下降。有沒有一種方法可以解決所有三個按鈕都在同一行中的問題?我嘗試使用TableLayout/但它沒有幫助。高度不匹配 - 按鈕

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/linearLayout1" 
    android:layout_alignParentBottom="true" android:layout_width="fill_parent" 
    android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"> 
      <Button android:text="Trade" 
       android:layout_weight="1" android:layout_height="wrap_content" 
       android:layout_width="0dip" ></Button> 
      <Button android:text="Set Alert"![enter image description here][2]     
       android:layout_weight="1" android:layout_height="wrap_content" 
       android:layout_width="0dip" ></Button> 
      <Button android:text="Add to watchlist"     
       android:layout_weight="1" android:layout_height="wrap_content" 
       android:layout_width="0dip"></Button> 

</LinearLayout> 

enter image description here

+0

我不能看到你所提到的圖片。你忘了添加鏈接嗎?會非常有幫助的,我無法弄清楚你想要從文本中完全做什麼。 – 2011-07-20 23:28:23

+0

錯過了之前添加圖片。它現在在那裏。 –

回答

0

我試過了,它適用於我,當我把你的上面的佈局,並設置android:layout_height 3個按鈕「fill_parent」。

(儘管這是一個有趣的問題,不知道爲什麼最後一個按鈕是有點偏移。)

+0

偉大的..工作!感謝 –

-1

如果你想在按鈕的線是不小的/不是一個具體的量更大,你可以嘗試:

Button b = null; 
b.setMaxLines(1); 
b.setMinLines(1); 

UPDATE:

b.setSingleLine();

+0

這刪除了第二行的內容..我正在尋找所有的按鈕在一條直線.. –