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);

猜你喜欢

转载自www.cnblogs.com/dubo-/p/9078142.html
今日推荐