Code example for RelativeLayout

Methods: getBottom, getPaddingBottom, getPaddingLeft, getPaddingRight, getTop

0
				if (!isVerticalScrollBarEnabled()) {
					setVerticalScrollBarEnabled(true);
				} 
				if (getFirstVisiblePosition() == 0 
						&& mRefreshState != REFRESHING) {
					if ((mRefreshView.getBottom() >= mRefreshViewHeight || mRefreshView
							.getTop() >= 0)
							&& mRefreshState == RELEASE_TO_REFRESH) {
						mRefreshState = REFRESHING;
						prepareForRefresh();// 准备刷新 
						onRefresh();// 刷新 
					} else if (mRefreshView.getBottom() < mRefreshViewHeight
							|| mRefreshView.getTop() <= 0) {
						resetHeader();// 中止刷新 
						setSelection(1);
					} 
				} 
				break; 
			case MotionEvent.ACTION_DOWN :
				mLastMotionY = y;// 获得按下y轴位置
				break; 
			case MotionEvent.ACTION_MOVE :
				// 计算边距 
				applyHeaderPadding(event);
				break; 
		} 
		return super.onTouchEvent(event);
	} 
 
	private void applyHeaderPadding(MotionEvent ev) {
		int pointerCount = ev.getHistorySize();
 
		for (int p = 0; p < pointerCount; p++) {
			if (mRefreshState == RELEASE_TO_REFRESH) {
				if (isVerticalFadingEdgeEnabled()) {
					setVerticalScrollBarEnabled(false);
				} 
 
				int historicalY = (int) ev.getHistoricalY(p);
 
				int topPadding = (int) (((historicalY - mLastMotionY) - mRefreshViewHeight) / 1.7);
 
				mRefreshView.setPadding(mRefreshView.getPaddingLeft(),
						topPadding, mRefreshView.getPaddingRight(),
						mRefreshView.getPaddingBottom());
			} 
		} 
	} 
 
	private void resetHeaderPadding() { 
		mRefreshView.setPadding(mRefreshView.getPaddingLeft(),
				mRefreshOriginalTopPadding, mRefreshView.getPaddingRight(),
				mRefreshView.getPaddingBottom());
	} 
 
	private void resetHeader() { 
		if (mRefreshState != TAP_TO_REFRESH) {
			mRefreshState = TAP_TO_REFRESH;
Experience pair programming with AI  Get Codota for Java