private void OnItemScrolled(RecyclerView recyclerView, int dx, int dy) { float ratio = ComputeRatio(recyclerView); float footerRatio = Math.Max(0, Math.Min(FOOTER_RATIO_START, ratio) - FOOTER_RATIO_DIFF) / FOOTER_RATIO_MAX; float avatarRatio = Math.Max(0, Math.Min(AVATAR_RATIO_START, ratio) - AVATAR_RATIO_DIFF) / AVATAR_RATIO_MAX; float answerRatio = Math.Max(0, Math.Min(ANSWER_RATIO_START, ratio) - ANSWER_RATIO_DIFF) / ANSWER_RATIO_MAX; float middleRatio = Math.Max(0, Math.Min(MIDDLE_RATIO_START, ratio) - MIDDLE_RATIO_DIFF) / MIDDLE_RATIO_MAX; ViewCompat.SetPivotY(mFooter, 0); ViewCompat.SetScaleY(mFooter, footerRatio); ViewCompat.SetAlpha(mFooter, footerRatio); ViewCompat.SetPivotY(mMiddleAnswer, mMiddleAnswer.Height); ViewCompat.SetScaleY(mMiddleAnswer, 1f - answerRatio); ViewCompat.SetAlpha(mMiddleAnswer, 0.5f - answerRatio); ViewCompat.SetAlpha(mHeaderCaption1, answerRatio); ViewCompat.SetAlpha(mHeaderCaption2, 1f - answerRatio); View mc2 = mMiddleCollapsible[1]; ViewCompat.SetPivotX(mc2, 0); ViewCompat.SetPivotY(mc2, mc2.Height / 2); foreach (View view in mMiddleCollapsible) { ViewCompat.SetScaleX(view, avatarRatio); ViewCompat.SetScaleY(view, avatarRatio); ViewCompat.SetAlpha(view, avatarRatio); } ViewGroup.LayoutParams lp = mMiddle.LayoutParameters; lp.Height = m120dp - (int)(m10dp * (1f - middleRatio)); mMiddle.LayoutParameters = lp; }