2016-08-30 40 views

回答

0

使用具有相等layout_weight水平的LinearLayout属性。然后将其放在垂直线性布局中:

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <View 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" /> 
     <View 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" /> 
     <View 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
    <View 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 
+0

GridLayout可能比嵌套LinearLayouts更好 –

+0

GridLayout中的权重取决于API版本 – breakline

+0

即使对于支持v7 gridlayout? –