Change TextSize of TabbarTitle in Android Programmatically

MichaelMeierMichaelMeier USMember ✭✭

I know there are lot's of samples of doing this but none of them works for me. I can change the colors, even the Text of a Tabbar Title but not the the size nor font. I tried through Custom TabbedPageRenderer. And I have a simple Demo project with a ExtendedTabbedPageRenderer.cs in the Android part.
The Application class is a FormsAppCompatActivity.


  • MichaelMeierMichaelMeier USMember ✭✭

    This is the code:
    ` protected override void OnVisibilityChanged(Android.Views.View changedView, [GeneratedEnum] ViewStates visibility)
    base.OnVisibilityChanged(changedView, visibility);

            if (visibility == ViewStates.Visible)
                TabLayout tabs = changedView.FindViewById<TabLayout>(Droid.Resource.Id.sliding_tabs);
                // Changing Colors is working
                tabs.SetTabTextColors(Android.Graphics.Color.Blue, Android.Graphics.Color.Red);
                ViewGroup vg = (ViewGroup)tabs.GetChildAt(0);
                int tabsCount = vg.ChildCount;
                for (int j = 0; j < tabsCount; j++)
                    ViewGroup vgTab = (ViewGroup)vg.GetChildAt(j);
                    int tabChildsCount = vgTab.ChildCount;
                    for (int i = 0; i < tabChildsCount; i++)
                        Android.Views.View tabViewChild = vgTab.GetChildAt(i);
                        if (tabViewChild is Android.Widget.TextView)
                            // This is working
                            ((Android.Widget.TextView)tabViewChild).Text = "TEST";
                            // This is all not working
                            ((Android.Widget.TextView)tabViewChild).SetTextSize(Android.Util.ComplexUnitType.Dip, 80.0f);
                            Font f = Font.OfSize("sans-serif", 8);
                            Typeface tf = FontExtensions.ToTypeface(f);
                            ((Android.Widget.TextView)tabViewChild).SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
Sign In or Register to comment.