0

我已经使用这个Vertically AutoScrolling Textview实现了一个水平滚动视图..但是没有描述如何使文本循环滚动..有什么帮助吗?

4

2 回答 2

1

在xml中添加这个:

<ScrollView 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:id="@+id/sc">


         <TextView
            android:id="@+id/mark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:singleLine="true"
            android:text="Thanks Christian but I am trying to get my text to scroll downwards automatically I am able to scroll horizontally fine."
            android:textSize="50dp"
            android:layout_above="@+id/btn"
            android:layout_below="@+id/txt"  />

     </ScrollView>

这在你的活动中:

ScrollView scrollView=(ScrollView) findViewById(R.id.sc);
        scrollView.post(new Runnable() {

            public void run() {
                scrollView.smoothScrollTo(0, scrollView.getBottom());
            }
        });
于 2012-07-10T12:55:48.990 回答
0

您可以通过在滚动视图到达底部时将其滚动回顶部来实现。这将使您的 ScrollView 无限循环。

像这样的东西-

public void scrollDown(final ScrollView v){
new CountDownTimer(2000, 20) { 

    public void onTick(long millisUntilFinished) { 
        if((2000 - millisUntilFinished)==v.getBottom())
              millisUntilFinished=2000;
        v.scrollTo((int) (0,2000 - millisUntilFinished)); 
    } 

    public void onFinish() { 

    } 
 }.start(); }

虽然我自己没有尝试过,但逻辑应该有效。

于 2012-07-10T13:15:26.853 回答