开发者

Question about using ellipseize in TextView

开发者 https://www.devze.com 2023-03-17 14:47 出处:网络
I am using ellipseize in my text view. From here, it said it should truncated. But I don\'t see it get truncted.Basically, I want 2 textfields next to each other.

I am using ellipseize in my text view. From here, it said it should truncated. But I don't see it get truncted. Basically, I want 2 textfields next to each other. txt1 on the right and txt2 on the left. I want the txt2 truncated when it is too long. But what I am seeing now is it is overlapping the text of 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>


I think you want android:layout_toLeftOf="@id/txt1" in txt2, meaning txt2 is to the left of txt1. Looks like you are trying to layout to the right of a view which is aligned with the right of the parent currently.

0

精彩评论

暂无评论...
验证码 换一张
取 消