今天遇到了一個需要ScrollView在事件觸發(fā)后跳轉(zhuǎn)到頂端旺芽,查詢了一下有使用ScrollView中void scrollTo (int x,int y)這個方法的擒抛,嘗試了一下是可以實現(xiàn)的,但是如果是滑動到底部呢,所以這個方法明顯有點無力,查找了下官網(wǎng)找到了一個方法
fullScroll(int direction)
directionint: the scroll direction:FOCUS_UPto go the top of the view orFOCUS_DOWNto go the bottom
developer.android.com/reference/android/widget/ScrollView.html#fullScroll(int)
Handles scrolling in response to a "home/end" shortcut press. This method will scroll the view to the top or bottom and give the focus to the topmost/bottommost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.
大概意思就是:一個滾動到底部和頂部的快捷方式伊佃,傳遞的參數(shù)為FOCUS_UP或者FOCUS_DOWN可以實現(xiàn)這種需求。