private void InitToolbar() { try { ToolBar = FindViewById <Toolbar>(Resource.Id.toolbar); if (ToolBar != null) { ToolBar.Title = GetText(Resource.String.Lbl_Chats); ToolBar.SetTitleTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); SetSupportActionBar(ToolBar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); if (AppSettings.SetTabDarkTheme) { ToolBar.SetBackgroundResource(Resource.Drawable.linear_gradient_drawable_Dark); } } } catch (Exception e) { Console.WriteLine(e); } }
private void VisitsButtonOnClick(object sender, EventArgs e) { try { MAdapter.NotificationsList.Clear(); MAdapter.NotificationsList = ListUtils.VisitsList; MAdapter.NotifyDataSetChanged(); ToolbarView.SetBackgroundResource(Resource.Drawable.Shape_Gradient_Normal); VisitsImage.SetColorFilter(Color.ParseColor("#ffffff")); VisitsTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); VisitsLayout.SetBackgroundResource(Resource.Drawable.Shape_Radius_Gradient_Btn); VisitsButton.Tag = "Clicked"; ResetTabsButtonOnVistsClick(); if (MAdapter.NotificationsList.Count > 0) { MRecycler.Visibility = ViewStates.Visible; EmptyStateLayout.Visibility = ViewStates.Gone; } if (Methods.CheckConnectivity()) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => LoadVisitsAsync() }); } if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { return; } Activity.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); Activity.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Activity.Window.SetStatusBarColor(Color.ParseColor(AppSettings.MainColor)); } catch (Exception exception) { Console.WriteLine(exception); } }
void UpdateToolbarBackground(Android.Support.V7.Widget.Toolbar toolbar, Page lastPage, Activity activity, Android.Graphics.Drawables.Drawable defaultBackground) { if (string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(lastPage)) && CustomNavigationPage.GetGradientColors(lastPage) == null) { toolbar.SetBackground(defaultBackground); } else { if (!string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(lastPage))) { toolbar.SetBackgroundResource(this.Context.Resources.GetIdentifier(CustomNavigationPage.GetBarBackground(lastPage), "drawable", Android.App.Application.Context.PackageName)); } if (CustomNavigationPage.GetGradientColors(lastPage) != null) { var colors = CustomNavigationPage.GetGradientColors(lastPage); var direction = GradientDrawable.Orientation.TopBottom; switch (CustomNavigationPage.GetGradientDirection(lastPage)) { case CustomNavigationPage.GradientDirection.BottomToTop: direction = GradientDrawable.Orientation.BottomTop; break; case CustomNavigationPage.GradientDirection.RightToLeft: direction = GradientDrawable.Orientation.RightLeft; break; case CustomNavigationPage.GradientDirection.LeftToRight: direction = GradientDrawable.Orientation.LeftRight; break; } GradientDrawable gradient = new GradientDrawable(direction, new int[] { colors.Item1.ToAndroid().ToArgb(), colors.Item2.ToAndroid().ToArgb() }); gradient.SetCornerRadius(0f); toolbar.SetBackground(gradient); } } toolbar.Background.SetAlpha((int)(CustomNavigationPage.GetBarBackgroundOpacity(lastPage) * 255)); }