private void UpdateTabIcons() { var tabLayout = this.tabLayout; if (tabLayout.TabCount != this.Element.Children.Count) { return; } for (int i = 0; i < this.Element.Children.Count; ++i) { var page = this.Element.Children[i]; if (string.IsNullOrEmpty(page.Icon)) { var glyph = (string)page.GetValue(AttachedFontIcon.GlyphProperty); if (!string.IsNullOrWhiteSpace(glyph)) { SpannableStringBuilder sb = new SpannableStringBuilder(); sb.Append(glyph); var font = (string)page.GetValue(AttachedFontIcon.FontFamilyProperty); if (!string.IsNullOrWhiteSpace(font)) { var span = new CustomTypefaceSpan(font); sb.SetSpan(span, 0, glyph.Length, SpanTypes.ExclusiveExclusive); } //var size = (int)(double)page.GetValue(AttachedFontIcon.FontSizeProperty); sb.SetSpan(new AbsoluteSizeSpan(40), 0, glyph.Length, SpanTypes.ExclusiveExclusive); sb.Append("\n"); sb.Append(page.Title); //sb.SetSpan(new ForegroundColorSpan(Android.Graphics.Color.Red), 3, 4, SpanTypes.ExclusiveExclusive); //Must set app:tabTextAppearance textAllCaps to false. // See : tabs.xml, //if not do this, span will not work not work tabLayout.GetTabAt(i).SetText(sb); ////without specify color //var v = new TextView(this.Context) { // TextAlignment = Android.Views.TextAlignment.Center //}; //v.SetText(sb, TextView.BufferType.Spannable); //tabLayout.GetTabAt(i).SetCustomView(v); } } } }
static TextViewExt() { Rouble = Typeface.CreateFromAsset(Application.Context.Assets, "Rouble.ttf"); RoubleSpan = new CustomTypefaceSpan(Rouble); }
private void UpdateTabIcons() { var tabLayout = this.tabLayout; if (tabLayout.TabCount != this.Element.Children.Count) return; for (int i = 0; i < this.Element.Children.Count; ++i) { var page = this.Element.Children[i]; if (string.IsNullOrEmpty(page.Icon)) { var glyph = (string)page.GetValue(AttachedFontIcon.GlyphProperty); if (!string.IsNullOrWhiteSpace(glyph)) { SpannableStringBuilder sb = new SpannableStringBuilder(); sb.Append(glyph); var font = (string)page.GetValue(AttachedFontIcon.FontFamilyProperty); if (!string.IsNullOrWhiteSpace(font)) { var span = new CustomTypefaceSpan(font); sb.SetSpan(span, 0, glyph.Length, SpanTypes.ExclusiveExclusive); } //var size = (int)(double)page.GetValue(AttachedFontIcon.FontSizeProperty); sb.SetSpan(new AbsoluteSizeSpan(40), 0, glyph.Length, SpanTypes.ExclusiveExclusive); sb.Append("\n"); sb.Append(page.Title); //sb.SetSpan(new ForegroundColorSpan(Android.Graphics.Color.Red), 3, 4, SpanTypes.ExclusiveExclusive); //Must set app:tabTextAppearance textAllCaps to false. // See : tabs.xml, //if not do this, span will not work not work tabLayout.GetTabAt(i).SetText(sb); ////without specify color //var v = new TextView(this.Context) { // TextAlignment = Android.Views.TextAlignment.Center //}; //v.SetText(sb, TextView.BufferType.Spannable); //tabLayout.GetTabAt(i).SetCustomView(v); } } } }