【问题标题】:How to do such a layout in xml? Android如何在xml中做这样的布局?安卓
【发布时间】:2010-07-24 17:42:57
【问题描述】:

我想要一个和屏幕一样大的两行三列布局

喜欢那张图片 => http://dl.dropbox.com/u/2024237/Bildschirmfoto-DroidDraw.png

颜色应该是按钮...

请帮忙....我想不通

【问题讨论】:

    标签: java android xml layout


    【解决方案1】:

    使用 LinearLayouts 并在宽度和高度上将子级设置为 fill_parent 并为它们分配相同的 layout_weight 您将获得所需的效果:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <LinearLayout 
            android:orientation="horizontal"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <Button 
                android:text="Button 1"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
            <Button 
                android:text="Button 2"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
            <Button 
                android:text="Button 3"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <Button 
                android:text="Button 4"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
            <Button 
                android:text="Button 5"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
            <Button 
                android:text="Button 6"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></Button>
        </LinearLayout>
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-03
      • 2013-11-01
      • 1970-01-01
      • 2014-08-22
      • 1970-01-01
      • 1970-01-01
      • 2011-04-01
      相关资源
      最近更新 更多