简体   繁体   中英

Spinner in table layout does not align with EditText

My XML file is below. I have no idea what's wrong and making the spinner out of alignment when the datasource is bound. The alignment is OK before the data load. I am loading the data into the TableLayout below. Any ideas as to what may be causing this?

<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:dropDownWidth="match_parent"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM