Skip to content

Instantly share code, notes, and snippets.


Dmuasya/ Secret

Last active Dec 22, 2020
What would you like to do?
public class StickyNavLayout extends LinearLayout
private View mTop;
private View mNav;
private ViewPager mViewPager;
private int mTopViewHeight;
private ScrollView mInnerScrollView;
private boolean isTopHidden = false;
private OverScroller mScroller;
private VelocityTracker mVelocityTracker;
private int mTouchSlop;
private int mMaximumVelocity, mMinimumVelocity;
private float mLastY;
private boolean mDragging;
public StickyNavLayout(Context context, AttributeSet attrs)
super(context, attrs);
mScroller = new OverScroller(context);
mVelocityTracker = VelocityTracker.obtain();
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMaximumVelocity = ViewConfiguration.get(context)
mMinimumVelocity = ViewConfiguration.get(context)
protected void onFinishInflate()
mTop = findViewById(;
mNav = findViewById(;
View view = findViewById(;
if (!(view instanceof ViewPager))
throw new RuntimeException(
"id_stickynavlayout_viewpager show used by ViewPager !");
mViewPager = (ViewPager) view;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment