public void OnPageScrollStateChanged(int state) { if (Settings.DisplayToolbarWhenSwipe) { MaterialViewPagerHelper.GetAnimator(Context).OnViewPagerPageChanged(); } }
protected override IParcelable OnSaveInstanceState() { IParcelable superState = base.OnSaveInstanceState(); SavedState ss = new SavedState(superState) { Settings = Settings, YOffset = MaterialViewPagerHelper.GetAnimator(Context).LastYOffset }; //end return(ss); }
private void SetMaterialHeight() { //get the MaterialViewPagerAnimator attached to this activity //to retrieve the declared header height //and set it as current view height (+10dp margin) MaterialViewPagerAnimator animator = MaterialViewPagerHelper.GetAnimator(Context); if (animator != null) { ViewGroup.LayoutParams param = LayoutParameters; param.Height = (int)Math.Round(Utils.DpToPx(animator.GetHeaderHeight() + 10, Context)); LayoutParameters = param; } }
protected override void OnRestoreInstanceState(IParcelable state) { SavedState ss = (SavedState)state; base.OnRestoreInstanceState(ss.SuperState); Settings = ss.Settings; if (HeaderBackground != null) { HeaderBackground.SetBackgroundColor(new Color(Settings.Color)); } MaterialViewPagerAnimator animator = MaterialViewPagerHelper.GetAnimator(Context); //-1*ss.yOffset restore to 0 animator.RestoreScroll(-1 * ss.YOffset, ss.Settings); MaterialViewPagerHelper.Register(Context, animator); }
/** * Change the header color */ public void SetColor(int color, int fadeDuration) { MaterialViewPagerHelper.GetAnimator(Context).SetColor(color, fadeDuration * 2); }