2012-06-26 78 views
7

問題是我正在使用fullScroll()scrollTo()函數進行滾動,但它是動畫的,我需要它在沒有用戶觀察的情況下發生。如何在沒有動畫的情況下滾動水平滾動視圖

有沒有辦法解決這個問題?

hScrollView.post(new Runnable() { 
    @Override 
    public void run() { 
     hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT); 
    } 
}); 
+0

嘗試hScrollView.fullScroll(ScrollView.FOCUS_LEFT); –

+0

謝謝,但我之前嘗試過,我也遇到同樣的問題! – user1116209

+0

但動畫有什麼問題?如果他們看到滾動而不是跳轉到另一個位置,我認爲用戶體驗會更好。 –

回答

4

使用此

// Disable the animation First 
hScrollView.setSmoothScrollingEnabled(false); 
// Now scroll the view 
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT); 
// Now enable the animation again if needed 
hScrollView.setSmoothScrollingEnabled(true); 
相關問題