5

http://img683.imageshack.us/img683/645/weatherscreenmockupoutl.png

我问自己编写此布局的最佳方法是什么。基本上我只需要知道如何获得等宽的七列。

提前致谢!

4

5 回答 5

4

如果它是您想要的相等宽度,您可以使用具有相同权重的子元素的线性布局。查看以下 xml。

<LinearLayout
    layout:orientation="horizontal"
>
    <LinearLayout
      android:id = "@+id/firstcolumn"
      android:layout_weight="1"
      android:orientation="vertical"
      android:layout_width="0dp"
    >
    // do the same for your rest of the six children

</LinearLayout>
于 2011-10-25T07:47:14.180 回答
3

TableLayout似乎更好,因为列数不会改变。GridView你必须添加适配器和东西。

于 2011-10-25T07:43:48.897 回答
2

您可以将 TableLayout 与 TableRow 很好地结合起来,并根据需要制作行和列,非常容易。

这是一个带有 4 个按钮的 2x2 网格的示例(例如放在一个 LinearLayout 中):

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/button2"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button3"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/button4"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </TableRow>
</TableLayout>
于 2012-04-03T11:12:06.877 回答
0

最好是使用gridview。尝试这样的事情:

<GridView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:numColumns="7" />
于 2012-12-18T08:02:28.420 回答
0
/>
<GridView 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="7"
android:stretchMode="columnWidth"
android:gravity="center"
/>

试试这个..

于 2014-12-23T09:53:07.290 回答