下面的TextView在同一行上的EditText和Button?

Kev*_*ker 2 android android-layout

我试图在EditTexta旁边有一个小部件Button,也有一个TextView底部.本EditText应该调整,并相应地填满屏幕,而按钮的宽度应该永远只有它所需要的是(我通过设置宽度这样做wrap_content).

我想要完成的布局应该是相对的.下面是我到目前为止的代码(其中一些在StackOverflow上找到).删除TextView为EditText和Button提供了所需的外观,但是当添加TextView时,视图非常糟糕.

任何见解都会有帮助!

<?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_height="wrap_content" 
                android:orientation="horizontal"
                android:layout_width="fill_parent"
  >
    <EditText android:text="@+id/EditText01" 
              android:id="@+id/EditText01"
              android:layout_height="wrap_content" 
              android:layout_weight="1"
              android:layout_width="fill_parent"
    />

    <Button android:text="@+id/Button01" 
            android:id="@+id/Button01"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
    />

    <TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/hello"
    />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Fal*_*rri 9

试试这个:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:orientation="horizontal"
    android:layout_width="fill_parent">

    <Button

        android:text="@+id/Button01" 
        android:id="@+id/Button01"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true">
    </Button>

    <EditText android:text="@+id/EditText01" 
        android:id="@+id/EditText01"
        android:layout_height="wrap_content" 
        android:layout_toLeftOf="@id/Button01"
        android:layout_width="fill_parent">
    </EditText>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/EditText01"
        android:text="@string/hello"
    />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)