public void SetToolBar(Android.Support.V7.Widget.Toolbar toolbar, string title, bool setBackground, bool showIconBack = true) { try { if (toolbar != null) { if (!string.IsNullOrEmpty(title)) { toolbar.Title = title; } toolbar.SetTitleTextColor(AppSettings.SetTabDarkTheme ? AppSettings.TitleTextColorDark : AppSettings.TitleTextColor); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(showIconBack); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); if (setBackground) { toolbar.SetBackgroundResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.linear_gradient_drawable_Dark : Resource.Drawable.linear_gradient_drawable); } } } catch (Exception e) { Console.WriteLine(e); } }
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); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) { toolbar.SetBackground(gradient); } else { toolbar.SetBackgroundDrawable(gradient); } } } toolbar.Background.SetAlpha((int)(CustomNavigationPage.GetBarBackgroundOpacity(lastPage) * 255)); }
private void InitToolbar() { try { Toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); Toolbar.Title = GetString(Resource.String.Lbl_Forget_password); Toolbar.SetTitleTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); Toolbar.SetBackgroundResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.linear_gradient_drawable_Dark : Resource.Drawable.linear_gradient_drawable); SetSupportActionBar(Toolbar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); } catch (Exception e) { Console.WriteLine(e); } }
private void InitToolbar() { try { Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); if (toolbar != null) { toolbar.Title = GetString(Resource.String.Lbl_About); toolbar.SetTitleTextColor(AppSettings.SetTabDarkTheme ? AppSettings.TitleTextColorDark : AppSettings.TitleTextColor); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); toolbar.SetBackgroundResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.linear_gradient_drawable_Dark : Resource.Drawable.linear_gradient_drawable); } } catch (Exception e) { Console.WriteLine(e); } }
public void SetAppearance(Android.Support.V7.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { toolbar.SetBackgroundResource(Resource.Drawable.gradient); }