2015-06-14 54 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>