diff --git a/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java b/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java index dc1ea65..522047b 100755 --- a/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java +++ b/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java @@ -31,6 +31,7 @@ public class PtrFrameLayout extends ViewGroup { private final static byte FLAG_AUTO_REFRESH_BUT_LATER = 0x01 << 1; private final static byte FLAG_ENABLE_NEXT_PTR_AT_ONCE = 0x01 << 2; private final static byte FLAG_PIN_CONTENT = 0x01 << 3; + private final static byte FLAG_PIN_HEADER = 0x01 << 4; private final static byte MASK_AUTO_REFRESH = 0x03; protected View mContent; // optional config for define header and content in xml file @@ -424,9 +425,14 @@ private void updatePos(int change) { if (DEBUG) { PtrCLog.v(LOG_TAG, "updatePos: change: %s, current: %s last: %s, top: %s, headerHeight: %s", change, mPtrIndicator.getCurrentPosY(), mPtrIndicator.getLastPosY(), mContent.getTop(), mHeaderHeight); + PtrCLog.v(LOG_TAG, "updatePos: headerView: top: %s", mHeaderView.getTop()); } - mHeaderView.offsetTopAndBottom(change); + if (mHeaderView.getTop() <= PtrIndicator.POS_START){ + mHeaderView.offsetTopAndBottom(change); + } else if (!isPinHeader()) { + mHeaderView.offsetTopAndBottom(change); + } if (!isPinContent()) { mContent.offsetTopAndBottom(change); } @@ -742,6 +748,21 @@ public void setPinContent(boolean pinContent) { } } + public boolean isPinHeader() { + return (mFlag & FLAG_PIN_HEADER) > 0; + } + + /* + * The header move to visible,will not move when {@param pinHeader} set to true + */ + public void setPinHeader(boolean pinHeader){ + if (pinHeader) { + mFlag = mFlag | FLAG_PIN_HEADER; + } else { + mFlag = mFlag & ~FLAG_PIN_HEADER; + } + } + /** * It's useful when working with viewpager. *