0

我创建了一个包含两列的表格布局,它适用于横向: 景观

但只有一列纵向显示:

纵向

我尝试创建两个文件夹 layout-land & layout-port ,并将 xml 文件放入每个文件夹中,但没有成功。

这是带有表格布局的代码部分:

 <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/roundshape"
            android:shrinkColumns="*"
            android:stretchColumns="*" 
            >

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

                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_span="6"
                    android:background="@drawable/shape"
                    android:gravity="center"
                    android:padding="5dp"
                    android:text="Octave schedule"
                    android:textSize="18dp"
                    android:textStyle="bold"
                    android:typeface="serif" >
                </TextView>
            </TableRow>

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

                <TextView
                    android:id="@+id/TextView04"
                    android:background="@drawable/shape"
                    android:padding="5dp"
                    android:text="Event" >
                </TextView>

                <TextView
                    android:id="@+id/TextView05"
                    android:background="@drawable/shape"
                    android:padding="5dp"
                    android:text="date                                           " >
                </TextView>
            </TableRow>

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

                <TextView
                    android:id="@+id/textView2"
                    android:background="@drawable/shape"
                    android:padding="5dp"
                    android:text="Participants’ Briefing"
                    android:textStyle="bold" >
                </TextView>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/shape"
                    android:baselineAligned="true"
                    android:orientation="horizontal" >

                    <EditText
                        android:id="@+id/edittext1"
                        android:layout_width="0dip"
                        android:layout_height="25dip"
                        android:layout_weight="1"
                        android:hint="date"
                        android:maxLines="1"
                        android:textSize="10sp" />

                    <ImageButton
                        android:id="@+id/imageButton1"
                        style="@style/btnStyleGrey"
                        android:layout_width="0dip"
                        android:layout_height="25dip"
                        android:layout_weight="0.25"
                        android:src="@drawable/calendar2" />
                </LinearLayout>
                      ......
            </TableRow>
4

1 回答 1

0

我通过使用 *android:layout_weight* 解决了这个问题,其中 textViews 为 0.75,包含 imageButton 和 editText 的线性布局为 0.25。

于 2013-05-20T09:27:48.513 回答