protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (setup) { return; } if (e.PropertyName == "Renderer") { tabbedPage = (CoreTabbedPage)Element; if (!tabbedPage.IsToolbarBottom) { //var groupName = ViewGroup.GetChildAt(0).GetType().Name; layout = (TabLayout)ViewGroup.GetChildAt(1); setup = true; ColorStateList colors = CreateColorState(); layout?.SetTabTextColors(tabbedPage.UnSelectedForegroundColor.ToAndroid(), tabbedPage.SelectedForegroundColor.ToAndroid()); if (tabbedPage.TabBackgroundColor != Color.Default) { layout?.SetBackgroundColor(tabbedPage.TabBackgroundColor.ToAndroid()); } if (layout != null) { for (int i = 0; i < layout.TabCount; i++) { var tab = layout.GetTabAt(i); var icon = tab.Icon; if (icon != null) { icon = DrawableCompat.Wrap(icon); DrawableCompat.SetTintList(icon, colors); } } } } } }
void UpdateBarBackgroundColor() { if (IsDisposed) { return; } if (IsBottomTabPlacement) { Color tintColor = Element.BarBackgroundColor; if (tintColor.IsDefault) { _bottomNavigationView.SetBackground(null); } else if (!tintColor.IsDefault) { _bottomNavigationView.SetBackgroundColor(tintColor.ToAndroid()); } } else { Color tintColor = Element.BarBackgroundColor; if (Forms.IsLollipopOrNewer) { if (tintColor.IsDefault) { _tabLayout.BackgroundTintMode = null; } else { _tabLayout.BackgroundTintMode = PorterDuff.Mode.Src; _tabLayout.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid()); } } else { if (tintColor.IsDefault && _backgroundDrawable != null) { _tabLayout.SetBackground(_backgroundDrawable); } else if (!tintColor.IsDefault) { // if you don't create a new drawable then SetBackgroundColor // just sets the color on the background drawable that's saved // it doesn't create a new one if (_backgroundDrawable == null && _tabLayout.Background != null) { _backgroundDrawable = _tabLayout.Background; _wrappedBackgroundDrawable = ADrawableCompat.Wrap(_tabLayout.Background).Mutate(); } if (_wrappedBackgroundDrawable != null) { _tabLayout.Background = _wrappedBackgroundDrawable; } _tabLayout.SetBackgroundColor(tintColor.ToAndroid()); } } } }
private void SetUpViewPager(ViewPager viewPager) { try { StickersTabAdapter adapter = new StickersTabAdapter(ChildFragmentManager); if (AppSettings.ShowStickerStack0) { adapter.AddFragment(new StickerFragment1("GroupChatWindowActivity"), "0"); } if (AppSettings.ShowStickerStack1) { adapter.AddFragment(new StickerFragment2("GroupChatWindowActivity"), "1"); } if (AppSettings.ShowStickerStack2) { adapter.AddFragment(new StickerFragment3("GroupChatWindowActivity"), "2"); } if (AppSettings.ShowStickerStack3) { adapter.AddFragment(new StickerFragment4("GroupChatWindowActivity"), "3"); } if (AppSettings.ShowStickerStack4) { adapter.AddFragment(new StickerFragment5("GroupChatWindowActivity"), "4"); } if (AppSettings.ShowStickerStack5) { adapter.AddFragment(new StickerFragment6("GroupChatWindowActivity"), "5"); } if (AppSettings.ShowStickerStack6) { adapter.AddFragment(new StickerFragment7("GroupChatWindowActivity"), "6"); } viewPager.Adapter = adapter; Tabs.SetupWithViewPager(viewPager); Tabs.SetBackgroundColor(!AppSettings.SetTabDarkTheme ? Color.ParseColor(AppSettings.StickersBarColor) : Color.ParseColor(AppSettings.StickersBarColorDark)); if (Tabs.TabCount > 0) { for (int i = 0; i <= Tabs.TabCount; i++) { var stickerReplacer = Tabs.GetTabAt(i); if (stickerReplacer != null) { if (stickerReplacer.Text == "0") { stickerReplacer.SetIcon(Resource.Drawable.Sticker1).SetText(""); } if (stickerReplacer.Text == "1") { stickerReplacer.SetIcon(Resource.Drawable.sticker2).SetText(""); } if (stickerReplacer.Text == "2") { stickerReplacer.SetIcon(Resource.Drawable.Sticker3).SetText(""); } if (stickerReplacer.Text == "3") { stickerReplacer.SetIcon(Resource.Drawable.Sticker4).SetText(""); } if (stickerReplacer.Text == "4") { stickerReplacer.SetIcon(Resource.Drawable.Sticker5).SetText(""); } if (stickerReplacer.Text == "5") { stickerReplacer.SetIcon(Resource.Drawable.Sticker6).SetText(""); } if (stickerReplacer.Text == "6") { stickerReplacer.SetIcon(Resource.Drawable.Sticker7).SetText(""); } } } } } catch (Exception e) { Console.WriteLine(e); } }