简体   繁体   中英

android table layout top margin

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
<TableLayout
    android:background="#000000"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="0.95"
        android:layout_marginLeft="0.1dp"
        android:layout_marginBottom="0.1dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="0dp"
        >
        <EditText
            android:id="@+id/et_1"
            android:layout_weight="0.1"
            android:layout_marginRight="0.1dp"
            android:background="@color/color_white"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:text="hell wolrd"
            android:inputType="text"

            />
        <EditText
            android:id="@+id/et_2"
            android:layout_weight="0.55"
            android:layout_marginTop="0dp"
            android:layout_marginRight="0.1dp"
            android:background="@color/color_white"
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:paddingTop="5dp"
            android:text="hell wolrd"
            android:inputType="textCapSentences|textMultiLine"
            />
        <Spinner
            android:id="@+id/spinner_3"
            android:layout_weight="0.15"
            android:layout_marginRight="0.1dp"
            android:background="@color/color_white"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            ></Spinner>
        <EditText
            android:id="@+id/et_4"
            android:layout_weight="0.15"
            android:layout_marginRight="0.1dp"
            android:background="@color/color_white"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:inputType="text"
            />
    </TableRow>
</TableLayout>
</LinearLayout>

Here is my xml file which shows the following result.

在此处输入图片说明

But when I run the code, the screen displays this: The second edit text is giving problem. Kindly if anyone can help What could be the possible reason? Is this margin? Why it is happening when I am not changing anything in the Class file.

在此处输入图片说明

Please change

 android:layout_height="wrap_content"

in EditText(et_2) to

 android:layout_height="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