我有一个带有以下属性的TextView:
<TextView
android:id="@+id/appheader"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:layout_marginLeft="3dp"
android:textSize="21sp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"/>
实际上,当我单击TextView时,TextView仅滚动。但是我想在启动Activity时自动滚动它。我怎么能这样做?
答案 0 :(得分:2)
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="very long text to srollll dkfjadkfjkldjfkjdkghjhtudhfjhdjfkdfkadjsajekdfjak"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"/>
答案 1 :(得分:1)
默认情况下TextView
选框效果在获得焦点时有效。要创建自动选取框效果,您需要扩展TextView
类。请参阅此link以供参考。
答案 2 :(得分:1)
set android:scrollHorizontally="true"
。
还设置以下两个属性:
text.setMovementMethod(new ScrollingMovementMethod());
text.setSelected(true);