【发布时间】:2012-10-03 10:03:18
【问题描述】:
我的主布局中有一个 GridView,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:horizontalSpacing="1dp"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp" />
</LinearLayout>
生成这样的网格
每个单元格的内容是这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/btn_measurement" >
<Button
android:id="@+id/numerical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="---" />
</LinearLayout>
但我希望第 4 列占其他列的三分之一,但我不能。
我检查了链接:
GridView with different column sizes 和 Android GridView Column Stretching
但他们没有帮助。 :(
如果您认为我需要完全更改我的解决方案,请比提供一般线索更准确。 谢谢
【问题讨论】:
-
你需要一个交错视图。见github.com/gabrielemariotti/cardslib\
标签: android android-layout android-gridview column-width