2012-05-03 143 views
2

我有4個ImageViews被水平放置在LinearLayout中。我需要兩兩件事:如何在線性佈局中平均分離圖像視圖

  1. 如果空間是由它們的高度有限,我希望他們能夠相互
  2. 之間的平等空間分佈上的LinearLayout同樣,也就是說,如果空間是由它們的寬度的限制,我希望圖像縮小,以使它們都適合視圖。

任何想法? 謝謝!

回答

4

你可以嘗試weightSum

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" 
     android:weightSum="4"> 
     <!-- Put your imageViews here and set android:layout_weight="1" each --> 
</LinearLayout> 

您還可以設置和了minHeight minWidth

<LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:minHeight="20dp" 
      android:minWidth="20dp" 
    ></LinearLayout> 
+0

這是偉大的,謝謝!!!! –

+0

很高興幫助。 =) –

相關問題