1

I have a TextView with following attributes :

<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"/> 

Actually the TextView scrolls ONLY when I click the TextView. But I want to scroll it automatically when I launch the Activity. How can I do this ?

4

3 回答 3

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"/>
于 2012-04-23T07:47:19.267 回答
1

默认情况下TextView,选取框效果在获得焦点时起作用。要制作自动选取框效果,您需要扩展TextView类。请参阅此链接以供参考。

于 2012-04-23T07:36:44.137 回答
1

set android:scrollHorizontally="true"对于那个文本视图。

还要设置以下两个属性:

text.setMovementMethod(new ScrollingMovementMethod());

text.setSelected(true);
于 2014-07-07T10:26:33.927 回答