【发布时间】:2015-04-23 04:37:20
【问题描述】:
我正在尝试设置一个 RelativeLayout,其中两个 TextView 显示在一行上。第一个 TextView 应该左对齐。第二个 TextView 应该向右对齐。如果第二个 TextView 文本会扩展以与第一个 TextView 重叠,那么我想省略中间的文本。我不想省略第一个 TextView。
这是我想出的。问题是第二个 TextView 直接位于第一个 TextView 的右侧,而不是与最右侧对齐。好像我不能同时使用 alignParentRight 和 toRightOf。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="[DetailedType]"/>
<TextView
android:id="@+id/Right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/Left"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:ellipsize="middle"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="[CustomerName]"/>
</RelativeLayout>
【问题讨论】:
标签: android android-layout xamarin.android