我已经尝试了所有我能想到的方法来使这种字幕效果发挥作用。这是我的 xml:
<TextView android:id="@+id/curPlaying"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:singleLine="true"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:textColor="#83A602"
android:textSize="20dp"
android:text="Nothing Loaded" />
我将其设置为在代码中选择的。我认为它可能不起作用的唯一原因是代码以相对频繁的间隔修改文本。
Help?
您好,请尝试下面的代码,它对我来说工作正常......
<TextView
android:id="@+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="Simple application that shows how to use marquee, with a long text"
android:textColor="#ff4500" />
TextView tv = (TextView) this.findViewById(R.id.mywidget);
tv.setSelected(true); // Set focus to the textview
它正在我的三星 Galaxy ACE 手机上运行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)