转自:http://blog.csdn.net/sun18612393433/article/details/52372574
作者:Anthony_sun
- 在LineLayout中设置weightSum=1;
- 在GridView中设置layout_weight = 0.5即可实现;
代码如下:
<LinearLayout
android:id="@+id/container3LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<GridView
android:id="@+id/gv_clothes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:scrollbars="vertical"//添加垂直滚动条
android:layout_weight="0.5"/>//设置高度
</LineLayout>