现在我有两个textViews,一个在相对布局的左边对齐,一个在右边对齐。左边的文本比右边的文本长得多。在某些情况下,左边的文字是两行。发生这种情况时,此文本与右侧对齐的文本重叠。如何防止视图在相对布局中重叠?
反正有防止这种情况吗?或者有什么方法可以说出左侧的文本是否是两行,将文本放在第二行的右侧?
我在与名称和时间的麻烦到这里:
<RelativeLayout android:layout_width="wrap_content" android:id="@+id/relativeLayout" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10sp" android:textStyle="bold" android:textSize="16sp"></TextView>
<TextView android:layout_width="wrap_content" android:id="@+id/address" android:text="address" android:layout_height="wrap_content" android:layout_below="@+id/name" android:layout_alignLeft="@+id/name" android:layout_marginLeft="30sp"></TextView>
<TextView android:layout_width="wrap_content" android:layout_toRightOf="@+id/address" android:text="" android:layout_height="wrap_content" android:layout_alignTop="@+id/address" android:layout_alignBottom="@+id/address" android:id="@+id/crossStreet"></TextView>
<TextView android:layout_width="wrap_content" android:id="@+id/time" android:text="Time" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="10sp"></TextView>
</RelativeLayout>
太棒了。有效。我还将时间对准线性布局的右侧,以供将来参考。 – mergesort
我应该玩重量吗?我有.35和.65来使它工作,但.4和.6产生了有趣的结果 – mergesort