2012-03-14 63 views
1

我有RelativeLayout,它由TextView組成,我用它來擴充列表中的項目。佈局是這樣的:TextView字幕移位相鄰TextView

enter image description here

較大的標題文本有時是太長了,所以我設置的TextViewellipsize屬性字幕,其中砍下,你可以在圖片中看到。 問題是在pic(來自仿真器)中更加微妙,但在設備上,您可以更清楚地看到marquee將「Days Lent」標籤轉變爲未對齊。或者說,我相信帶有選取框的那一排有正確的對齊方式,但是沒有選取框的那個會以某種方式進一步拉動。

這只是發生在marquee設置,而不是常規的省略號end,這讓我覺得這是值得與字幕做動畫。我在下面包含了我的XML佈局,以便您可以看到事情的工作原理。代碼中的要點:標題電視有填充以將其從右邊緣推開; 「借出的日子」位於0號碼的相對左側;標題是alignParentLeft; 0號碼是aligneParentRight

我試着改變「天借」的填充,並與marqueeRepeatLimit混淆,以及只使用常規省略號。

所以:爲什麼這個錯位使用選取框時發生在相鄰TextView

感謝。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 
<TextView 
    android:id="@+id/title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="24sp" 
    android:layout_alignParentLeft="true" 
    android:paddingRight="70dp" 
    android:paddingTop="3dp" 
    android:paddingBottom="3dp" 
    android:textColor="@color/green" 
    android:ellipsize="marquee" 
    android:singleLine="true" /> 
<TextView 
    android:id="@+id/description" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="13sp" 
    android:layout_below="@id/title" 
    android:layout_alignParentLeft="true" 
    android:paddingRight="70dp"/> 
<TextView 
    android:id="@+id/date" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="13sp" 
    android:layout_below="@id/description" 
    android:layout_alignParentLeft="true" 
    android:paddingBottom="3dp"/> 

<TextView 
    android:id="@+id/days" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="32sp" 
    android:paddingRight="10dp" 
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    /> 
<TextView 
    android:id="@+id/label" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="11sp" 
    android:paddingRight="5dp" 
    android:text="Days\nLent" 
    android:layout_toLeftOf="@id/days" 
    android:layout_centerVertical="true"/> 

回答

0

嗯,這是愚蠢的......我只是做了標題fill_parent,而不是wrap_content使每個標題拉伸一路之隔的行,然後有填充在右側。因此,他們都基本上是相同的長度視圖,並解決了對齊問題。