关于在TextView中使用ellipseize的问题

时间:2011-07-06 18:34:35

标签: android

我在文本视图中使用了ellipseize。从这里,它说它应该被截断。 但我不认为它会被截断。基本上,我想要彼此相邻的两个文本字段。 右边是txt1,左边是txt2。我希望txt2在太长的时候被截断。但我现在看到的是它与txt1的文本重叠。

http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize

        <RelativeLayout
            android:id="@+id/one"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        <TextView
            android:id="@+id/txt1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:singleLine="true"
            android:layout_centerVertical="true"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="?android:attr/textColorPrimary"/>
        <TextView
            android:id="@+id/txt2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_toRightOf="@id/txt1"
            android:ellipsize="end"
            android:singleLine="true"
            android:layout_weight="1"
            android:layout_centerVertical="true"
            />

        </RelativeLayout>

1 个答案:

答案 0 :(得分:0)

我认为你想在txt2中android:layout_toLeftOf="@id/txt1",意味着txt2在txt1的左边。看起来您正在尝试布局到与当前父级右侧对齐的视图右侧。