android relativelayout两行,列在右侧

android relativelayout两行,列在右侧,android,android-relativelayout,Android,Android Relativelayout,我试图实现一个左两行的浮动右文本视图,它将有一个数字。这是一个listview项目布局 ____ ___________________________ | | ___________________________ |____| 所以内容应该是这样的 LINE ONE CAN SOMETIMES BE LONG £2000.00 line two 然而,较大的文本大小为£2000.00,或者与下面的代码示例重叠

我试图实现一个左两行的浮动右文本视图,它将有一个数字。这是一个listview项目布局

                               ____
___________________________   |    |
___________________________   |____|
所以内容应该是这样的

LINE ONE CAN SOMETIMES BE LONG   £2000.00
line two
然而,较大的文本大小为£2000.00,或者与下面的代码示例重叠,或者使用android:layout_toRightOf=@+id/row1,它基本上位于第1行旁边,如果第1行较长,有时会进入下一行。它应该始终在一行中

有人能帮忙吗

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="6dp" >

    <TextView
        android:id="@+id/row1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/rightcol"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textColor="#cc0000"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/row2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/row1" />

</RelativeLayout>
此时,右列文本与第1行重叠

感谢您检查android:layout\u权重将有助于实现所需的布局,请参阅。您可以在右侧文本视图中使用android:layout\u width=wrap\u内容,而不是50dp。其他文本视图将进行调整以填充剩余空间。您可以使用android:singleLine=true来限制您的文本视图,以便它们不会换行

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

    </LinearLayout>

    <TextView
        android:layout_width="50dp"
        android:layout_height="50dp"/>

</LinearLayout>
如果你打算使用RelativeLayout,这应该可以

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="6dp" >

    <TextView
        android:id="@+id/row1"
        android:text="This text can be very, very long"
        android:singleLine="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/rightcol"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/rightcol"
        android:text="$2000000000000.00"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textColor="#cc0000"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/row2"
        android:text="Second line of text"
        android:singleLine="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/rightcol"
        android:layout_below="@+id/row1" />

</RelativeLayout>
添加了android:singleLine=true,但由于金额浮动在第1行之上,所以它并没有真正的帮助。我知道这可以通过两个线性布局来实现,但我有点专注于让relativelayout用最少的xml来完成这项工作。如果没有,那么我可以随时回复LL。再次感谢您将android:layout_-toLeftOf=@+id/rightcol添加到两个左侧文本视图中。android:layout_-toLeftOf完成了这项工作。我必须让这两行填充,重力向左,否则它是右对齐的。谢谢你,伙计。我将向上投票,但当前答案无法回答问题,因此请更新,以便我可以将其标记为正确答案