表格布局范围无法正常工作

时间:2011-09-16 10:56:28

标签: android xamarin.android

我正在尝试实现表格布局,但屏幕左边框和第一列之间有间隙。

其次,我无法在第一行屏幕中为我的微调器提供所需的宽度,这总是占据整个屏幕宽度。

我尝试过使用拉伸列和layout_span的不同代码排列,但它们似乎不起作用。

 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:paddingLeft="0dp>![enter image description here][1]





            <TableRow>
                <TextView
                    android:layout_column="1"
                    android:text="Adult 1"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="10dp"
                    android:layout_width="wrap_content"
                    style="@style/text"/>


                <Spinner
                   android:layout_width="20dp"
                    android:layout_marginLeft="2dip"
                   android:layout_column="2"
                    android:layout_height="30dp"
                    android:layout_marginTop="10dp"
                     android:layout_marginBottom="5dp"
                    android:background="@drawable/select_spinner"
                    android:entries="@array/Passenger_title"/>



                <EditText

                  android:id="@+id/First_Name"
                  android:layout_column="3"
                  android:layout_width="wrap_content"

                  android:layout_height="30dp"
                  android:layout_marginTop="10dp"
                  style="@style/Edit_box_background"
                  android:layout_marginLeft="5dip"
                   android:layout_marginBottom="3dp"
                  android:textColor="#B3B3B3"
                  android:hint=" First Name  "
                  android:textAppearance="?android:attr/textAppearanceSmallInverse"
                  android:padding="3dip"/>

                <EditText

                 android:id="@+id/Last_Name"
               android:layout_column="4"
                   android:layout_width="wrap_content"

                 android:layout_height="30dp"
                 android:layout_marginTop="10dp"
                 style="@style/Edit_box_background"
                 android:layout_marginLeft="3dip"
                  android:layout_marginBottom="5dp"
                 android:textColor="#B3B3B3"
                 android:hint=" Last Name  "
                 android:textAppearance="?android:attr/textAppearanceSmallInverse"
                 android:padding="3dip"/>


            </TableRow>

1 个答案:

答案 0 :(得分:1)

首先查看您的场景我首先建议不要使用android:layout_column =“1”和layout_span,除非必需。默认情况下,添加到TableRow的所有项目都将从第一列开始添加到右侧。

然后给你的Spinner提供所需的宽度。

还有一个错误,你正在制作android:layout_column =“0”你忘了使用它使用第一列作为索引0而不是1.

希望我的建议可以帮助你并将你引向正确的方向。

相关问题