2012-03-03 58 views
2

我想爲短文本使用滾動字幕屬性。我寫了這段代碼:使用短文本時,滾動字幕不會滾動

<TextView 
     android:id="@+id/MarqueeText" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ellipsize="marquee" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:freezesText="true" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:paddingLeft="15dip" 
     android:paddingRight="15dip" 
     android:scrollHorizontally="true" 
     android:singleLine="true" 
     android:text="Hello" > 

它不起作用。但是當我將文字改爲「你好,你好,你好,你好,你好,等等。」 (長文本)它的作品。我怎樣才能使用選取框短文本?

回答

6

而不是fill_parent爲您的layout_width,使用設置寬度。當字符長度超過視圖寬度時,選框會啓用。

+0

非常感謝你,你救了我! – 2012-03-04 17:49:04

+0

不客氣。請記住標記我的答案爲已接受。 :) – 2012-03-04 21:00:35

+1

這對我沒有任何影響。 – Leon 2015-12-03 12:00:29