Marquee won't scroll when using short text

这一生的挚爱 提交于 2019-12-22 14:15:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!