问题
I want to use the marquee property for short texts. I wrote this code:
<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" >
and it doesn't work. But when I changed the text as "hello hello hello hello hello etc." (long text) it works. How can I use marquee for short texts?
回答1:
Instead of fill_parent
for your layout_width
, use a set width. The marquee is enabled when the characters are longer than the View's width.
来源:https://stackoverflow.com/questions/9549434/marquee-wont-scroll-when-using-short-text