2015-06-14 53 views
0

我目前的想法是使用1/2的水平LinearLayout作爲Weightsum,但不會使Linearlayout佔據屏幕的1/2(這將允許我在頂部放置Gridlayout)。如何讓網格佈局佔據屏幕的1/2?

我該如何讓Gridlay佔據屏幕的上半部分?

回答

0

嘗試設置父項LinearLayout上的weightSum屬性。

在下面的示例中,GridLayout的權重將爲中的總數2(如此一半)。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="2"> 

    <GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 
</LinearLayout>