【问题标题】:Spinner in table layout does not align with EditText表格布局中的微调器与 EditText 不对齐
【发布时间】:2015-06-01 13:34:40
【问题描述】:

我的 XML 文件在下面。我不知道出了什么问题,并且在绑定数据源时使微调器不对齐。在数据加载之前对齐是好的。我正在将数据加载到下面的TableLayout 中。关于可能导致这种情况的任何想法?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="onetech.smartsurvey.acStudent"
android:id="@+id/rl_student">

<LinearLayout
    android:id="@+id/ll_student"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >


    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/tl_student"
        android:orientation="horizontal"
        >

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/tr_student1"
            android:layout_margin="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="IC/Passport"
                android:id="@+id/tv_icPassport"
                android:textSize="16dp" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/et_icPassport"
                android:ems="10"
                android:layout_column="2"/>
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/tr_student2"
            android:layout_margin="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Nama"
                android:id="@+id/tv_StudentName"
                android:textIsSelectable="false"
                android:textSize="16dp" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/et_studentName"
                android:ems="10"
                android:layout_column="2" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/tr_student3"
            android:layout_margin="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Telefon"
                android:id="@+id/tv_phone"
                android:textSize="16dp" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/et_phone"
                android:ems="10"
                android:layout_column="2"/>
        </TableRow>

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


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Lokasi"
                android:id="@+id/tv_location"
                android:textSize="16dp" />

            <Spinner
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/spnr_location"
                android:spinnerMode="dropdown" />

        </TableRow>
    </TableLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="244dp"
        android:layout_height="83dp"
        android:layout_gravity="right">

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ibtn_OK"
            android:focusableInTouchMode="false"
            android:src="@drawable/ok"/>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ibtn_Reset"
            android:focusableInTouchMode="false"
            android:src="@drawable/reset"/>
</LinearLayout>
</LinearLayout>

【问题讨论】:

    标签: android android-tablelayout


    【解决方案1】:

    试试这个,

    android:dropDownWidth="match_parent"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 2012-07-13
      • 2012-12-09
      • 2012-07-24
      • 1970-01-01
      相关资源
      最近更新 更多