ScrollView 定位

1.固定到顶部
scroll_view.requestFocusFromTouch();
scroll_view.setScrollX(0);

2.固定到指定位置
 int[] location = new int[2];  
    titleTwo.getLocationOnScreen(location);  
    int offset = location[1] - mRootScrollView.getMeasuredHeight();  
    if (offset < 0) {  
        offset = 0;  
    }  
    mRootScrollView.smoothScrollTo(0, offset);

滚到到底部:
mRootScrollView.fullScroll(ScrollView.FOCUS_DOWN);


滚动到顶部:
mRootScrollView.fullScroll(ScrollView.FOCUS_UP);
posted @ 2018-05-23 17:52  dub  阅读(160)  评论(0编辑  收藏  举报