2013-10-26 19 views
0

我正在這樣做是爲了讓我的TextView滾動:的TextView和ScrollingMovementMethod麻煩

myTextView.setMovementMethod(new ScrollingMovementMethod()); 

我想是可以的,上創建,有我的TextView的可見部分的一定行我選擇的文字。

現在,它只是顯示TextView中文本的頂部,允許向下滾動。

有沒有辦法讓我能夠設置我想要滾動的起始位置?我無休止地搜索,但無濟於事。謝謝。

回答

0

這可以幫助試一下。

final int amount = yourTextView.getLayout().getLineTop(yourTextView.getLineCount()) - yourValue; 
    // if there is no need to scroll, amount will be <=0 
    if (amount > 0) 
     yourTextView.scrollTo(0, amount); 
    else 
     yourTextView.scrollTo(0, 0);