private void AddTab(int position, string title, View tabView) { var textView = tabView.FindViewById <TextView> (Resource.Id.tab_title); if (textView != null) { if (title != null) { textView.Text = title; } var alpha = pager.CurrentItem == position ? tabTextSelectedAlpha : tabTextAlpha; ViewCompat.SetAlpha(textView, alpha); } tabView.Focusable = true; tabView.Click += (object sender, EventArgs e) => { if (pager.CurrentItem != position) { var tab = tabsContainer.GetChildAt(pager.CurrentItem); NotSelected(tab); pager.SetCurrentItem(position, true); } else if (OnTabReselectedListener != null) { OnTabReselectedListener.OnTabReselected(position); } }; tabsContainer.AddView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
public void OnOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { int maxScroll = appBarLayout.TotalScrollRange; float percentage = (float)Math.Abs(verticalOffset) / (float)maxScroll; ViewCompat.SetAlpha(statusBarView, percentage); }
void Selected(View tab) { if (tab == null) { return; } var title = tab.FindViewById <TextView> (Resource.Id.tab_title); if (title == null) { return; } title.SetTypeface(tabTypeface, tabTypefaceSelectedStyle); ViewCompat.SetAlpha(title, tabTextSelectedAlpha); }
public static void AnimateBgColorChange(View clickedView, View backgroundView, View bgOverlay, int newColor) { var centerX = (int)(ViewCompat.GetX(clickedView) + (int)(clickedView.MeasuredWidth / 2)); var centerY = clickedView.MeasuredHeight / 2; var finalRadius = backgroundView.Width; backgroundView.ClearAnimation(); bgOverlay.ClearAnimation(); object animator; if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { if (!bgOverlay.IsAttachedToWindow) { return; } animator = ViewAnimationUtils.CreateCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius); } else { ViewCompat.SetAlpha(bgOverlay, 0); animator = ViewCompat.Animate(bgOverlay).Alpha(1); } var compat = animator as ViewPropertyAnimatorCompat; if (compat != null) { compat .SetListener(new CustomViewPropertyAnimatorListenerAdapter(backgroundView, newColor, bgOverlay)) .Start(); } else if (animator != null) { ((Animator)animator).AddListener(new CustomAnimatorListenerAdapter(backgroundView, newColor, bgOverlay)); ((Animator)animator).Start(); } bgOverlay.SetBackgroundColor(new Color(newColor)); bgOverlay.Visibility = ViewStates.Visible; }
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; }
private void OnCancel() { _backgroundView.SetBackgroundColor(_newColor); _bgOverlay.Visibility = ViewStates.Invisible; ViewCompat.SetAlpha(_bgOverlay, 1); }
/// <summary> /// Android4.4ÉÏCollapsingToolbarÕÛµþʱstatusBarÏÔʾºÍÒþ²Ø /// </summary> /// <param name="appBarLayout"></param> private static void SetCollapsingToolbarStatus(AppBarLayout appBarLayout) { ViewCompat.SetAlpha(statusBarView, 1); appBarLayout.AddOnOffsetChangedListener(new AppBarLayoutOffsetChanged()); }