/// <summary> /// Updates the menu item icons. /// </summary> private void UpdateTabbedIcons() { var relativeLayout = (Android.Widget.RelativeLayout)GetChildAt(0); var bottomNav = (BottomNavigationView)relativeLayout.GetChildAt(1); if (bottomNav == null || bottomNav.ChildCount == 0) { return; } for (var i = 0; i < bottomNav.Menu.Size(); i++) { var menuItemId = bottomNav.Menu.GetItem(i).ItemId; var menuItem = bottomNav.Menu.FindItem(menuItemId); if (_icons != null && i < _icons.Count) { var iconKey = _icons[i]; var drawable = new IconDrawable(Context, iconKey).Color(Color.White.ToAndroid()).SizeDp(20); menuItem.SetIcon(drawable); } } }
/// <summary> /// Updates the tabbed icons. /// </summary> private void UpdateTabbedIcons(Context context) { var tabLayout = FindViewById <TabLayout>(IconControls.TabLayoutId); if (tabLayout == null || tabLayout.TabCount == 0) { return; } for (var i = 0; i < tabLayout.TabCount; i++) { var tab = tabLayout.GetTabAt(i); if (_icons != null && i < _icons.Count) { var iconKey = _icons[i]; var icon = Plugin.Iconize.Iconize.FindIconForKey(iconKey); if (icon == null) { continue; } var drawable = new IconDrawable(context, icon).Color(Color.White.ToAndroid()).SizeDp(20); tab.SetIcon(drawable); } } }
/// <summary> /// Gets the toolbar item drawable. /// </summary> /// <param name="toolbarItem">The toolbar item.</param> /// <param name="context">The context.</param> /// <returns></returns> private static Drawable GetToolbarItemDrawable(this ToolbarItem toolbarItem, Context context) { if (String.IsNullOrWhiteSpace(toolbarItem.Icon)) { return(null); } var iconItem = toolbarItem as IconToolbarItem; if (iconItem == null) { return(context.Resources.GetDrawable(toolbarItem.Icon)); } var drawable = new IconDrawable(context, iconItem.Icon); if (drawable == null) { return(null); } if (iconItem.IconColor != Color.Default) { drawable = drawable.Color(iconItem.IconColor.ToAndroid()); } return(drawable.ActionBarSize()); }
/// <summary> /// Updates the tabbed icons. /// </summary> private void UpdateTabbedIcons(Context context) { var tabLayout = FindViewById <TabLayout>(Iconize.TabLayoutId); if (tabLayout == null || tabLayout.TabCount == 0) { return; } var element = (FlatTabbedPage)this.Element; for (var i = 0; i < tabLayout.TabCount; i++) { var tab = tabLayout.GetTabAt(i); if (_icons != null && i < _icons.Count) { var iconKey = _icons[i]; int.TryParse($"{element.FontSize}", out var fontSize); var drawable = new IconDrawable(context, iconKey, element.FontFamily).Color(Color.White.ToAndroid()).SizeDp(fontSize); tab.SetIcon(drawable); } } }
public void AppenIconForMenu(IMenu menu) { for (int i = 0; i < menu.Size(); i++) { var item = menu.GetItem(i); var iconized = Iconize.FindIconForKey("fa-envelope"); if (iconized != null) { var drawable = new IconDrawable(this, iconized).Color(Android.Graphics.Color.ParseColor("#7fadf7")).SizeDp(30); item.SetIcon(drawable); } } }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { //Color.Red, //Selected //Color.White //Normal Color.White, //Selected Color.LightGray //Normal }); //BottomTabbedRenderer.BackgroundColor = new Color(0x9C, 0x27, 0xB0); BottomTabbedRenderer.BackgroundColor = new Color(0x21, 0x96, 0xF3); //BottomTabbedRenderer.FontSize = 12f; BottomTabbedRenderer.FontSize = 14f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; //BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "architep.ttf"); //BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "HiraginoKakugoProNW3.otf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 4; //BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 56; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.ShouldUpdateSelectedIcon = true; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource, selected); return; } //var drawable = new IconDrawable(this, iconized).Color(selected ? Color.Red : Color.White).SizeDp(30); var drawable = new IconDrawable(this, iconized).Color(selected ? Color.White : Color.LightGray).SizeDp(30); menuItem.SetIcon(drawable); }; }
/// <summary> /// Updates the image. /// </summary> private void UpdateImage() { var iconImage = Element as IconImage; var icon = Plugin.Iconize.Iconize.FindIconForKey(iconImage.Icon); if (icon == null) { Control.SetImageResource(Android.Resource.Color.Transparent); return; } var drawable = new IconDrawable(Context, icon).Color(iconImage.IconColor.ToAndroid()) .SizeDp(iconImage.IconSize > 0 ? (Int32)iconImage.IconSize : (Int32)Element.HeightRequest); Control.SetScaleType(iconImage.IconSize > 0 ? ImageView.ScaleType.Center : ImageView.ScaleType.FitCenter); Control.SetImageDrawable(drawable); }
private void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Android.Graphics.Color.ParseColor("#7fadf7"), //Selected Android.Graphics.Color.ParseColor("#9b9797") //Normal }); //new Color(Resource.Color.colorPrimary) //Normal //{StaticResource Primary} //new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD2D2D2")); //System.Drawing.Color sdColor2 = Xamarin.Forms.Color.FromHex("FF6A00"); BottomTabbedRenderer.BackgroundColor = Android.Graphics.Color.ParseColor("#e5e0e0"); BottomTabbedRenderer.FontSize = 11f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "iconize-fontawesome.ttf"); //BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 2; //BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 50; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.ShouldUpdateSelectedIcon = true; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource, selected); return; } var drawable = new IconDrawable(this, iconized).Color(selected ? Android.Graphics.Color.ParseColor("#7fadf7") : Android.Graphics.Color.ParseColor("#9b9797")).SizeDp(30); menuItem.SetIcon(drawable); }; }
private static Drawable GetToolbarItemDrawable(this ToolbarItem toolbarItem, Context context) { if (String.IsNullOrWhiteSpace(toolbarItem.Icon)) { return(null); } if (!(toolbarItem is IconToolbarItem iconItem)) { return(context.GetDrawable(toolbarItem.Icon.File)); } var drawable = new IconDrawable(context, iconItem.Icon.File, iconItem.FontFamily); if (iconItem.IconColor != Color.Default) { drawable = drawable.Color(iconItem.IconColor.ToAndroid()); } return(drawable.ActionBarSize()); }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { new Color(67, 163, 245), //Selected new Color(187, 188, 190) //Normal }); BottomTabbedRenderer.BackgroundColor = new Color(23, 31, 50); BottomTabbedRenderer.FontSize = 12.5f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "architep.ttf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 24; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(12); BottomTabbedRenderer.BottomBarHeight = 160; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Top; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource); return; } var drawable = new IconDrawable(this, iconized).Color(Color.White).SizeDp(20); menuItem.SetIcon(drawable); }; }
public MoveElementAction(IconDrawable element, System.Drawing.Point oldCoordinates, System.Drawing.Point newCoordinates) { this.element = element; this.OldCoordinates = oldCoordinates; this.NewCoordinates = newCoordinates; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); /* Needs to be registered only on the MainLauncher */ Iconize.With(new MaterialModule()); SetSupportActionBar(_toolbar); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); /* * See Material Font Cheetsheat Here: https://goo.gl/FMCiR9 */ var icon = new IconDrawable(this, "md-menu"); icon.Color(Color.White); /* Sets the size to the action bar, ready to put it there */ icon.ActionBarSize(); /* Add the icon the the ActionBar */ SupportActionBar.SetHomeAsUpIndicator(icon); /* Implement the Hamburger Menu Selection Changed */ _navigationView.NavigationItemSelected += (sender, item) => { // Open Fragments Here Android.Support.V4.App.Fragment selectedFragment; switch (item.MenuItem.ItemId) { case Resource.Id.recommendations: selectedFragment = new SearchUserFragment(); break; default: selectedFragment = new ResultsTabFragment(); break; } try { SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.fragmentContainer, selectedFragment) .Commit(); item.MenuItem.SetChecked(true); _drawerLayout.CloseDrawers(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } }; _navigationView.SetCheckedItem(Resource.Id.recommendations); try { SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.fragmentContainer, new SearchUserFragment()) .Commit(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } }