Eclipse 说 TableRow 没用,但我找不到更好的方法

Eclipse says a TableRow is useless but I can't find a better way

我正在开发一个 Android 应用程序,我想知道我是否可以做一些不同的事情 and/or 更好以避免来自 Eclipse 的警告。为清楚起见,我将包含完整的 XML 布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#262626"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="#262626"
        android:gravity="center"
        android:paddingBottom="5.0dp"
        android:paddingTop="10dp"
        android:text="@string/title_rcon_console"
        android:textColor="#FFFFFF"
        android:textSize="20.0sp" />

    <TextView
        android:id="@+id/rcon_console"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/command_table"
        android:layout_below="@+id/title"
        android:background="#000000"
        android:gravity="left"
        android:paddingBottom="5.0dp"
        android:paddingTop="5.0dp"
        android:scrollbars="horizontal|vertical"
        android:text=""
        android:textColor="#FFFFFF"
        android:textSize="9.0sp"
        android:typeface="monospace" />

    <TextView
        android:id="@+id/sending"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/rcon_console"
        android:layout_centerHorizontal="true"
        android:background="#262626"
        android:gravity="center_vertical|center_horizontal"
        android:paddingBottom="5.0dp"
        android:paddingLeft="10.0dp"
        android:paddingRight="10.0dp"
        android:paddingTop="5.0dp"
        android:text="@string/msg_rcon_sending"
        android:textColor="#FFFFFF"
        android:textSize="14.0sp" />

    <TableLayout
        android:id="@+id/command_table"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#262626"
        android:paddingBottom="5.0dp"
        android:paddingTop="5.0dp"
        android:stretchColumns="0" >

        <TableRow>

            <EditText
                android:id="@+id/field_command"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="left|center_vertical"
                android:singleLine="true"
                android:inputType="text"
                android:text=""
                android:textSize="14.0sp" />

            <Button
                android:id="@+id/send_button"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_horizontal|center_vertical"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="@string/button_send" />

        </TableRow>

    </TableLayout>

</RelativeLayout>

问题出在 TableLayoutTableRow 元素上。 Eclipse 显示 TableRow 的以下警告:

This TableRow layout or its TableLayout parent is useless; transfer the background attribute to the other view

我正在使用 TableLayout,因为这是我能找到的并排对齐 EditTextButton 并让 EditText 跨越整个space 未被Button 占用。最终结果如下所示:

那么,Eclipse 说一个或两个 table 元素没有用是正确的吗?我可以用不同的或更合适的方式来做,并得到相同的结果吗?或者这只是一个虚假的警告,在这里不适用并且可以忽略?非常感谢任何帮助。

如果你这样做会怎样?

    <RelativeLayout
    android:id="@+id/command_table"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="#262626"
    android:paddingBottom="5.0dp"
    android:paddingTop="5.0dp"
     >

        <Button
            android:id="@+id/send_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:gravity="center_horizontal|center_vertical"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:text="@string/button_send" />



        <EditText
            android:id="@+id/field_command"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="left|center_vertical"
            android:layout_toLeftOf="@id/send_button"
            android:singleLine="true"
            android:inputType="text"
            android:text=""
            android:textSize="14.0sp" />



</RelativeLayout>

关于此方法的另一个不错的怪癖是,无论您在屏幕上放置什么内容,此 EditText 和 Button 组合将始终保持在您想要避免的软 keyboard.If 之上,然后 ir 需要一个更多工作