How to change the default tabbar's tab font on Xamarin.Android

aga913aga913 Member ✭✭

hi, the title pretty much describes what i want here.
simply a way to change the font of the tabs on the tabbar to another font.

Best Answers

Answers

  • suraj007suraj007 Member ✭✭✭
    Accepted Answer

    <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    app:tabGravity="fill"
    app:tabMode="fixed"
    app:tabTextAppearance="@style/MyCustomTabLayout"/&gt;

    in style.xml

    ?attr/colorAccent ?attr/selectableItemBackground @style/MyCustomTabTextAppearance ?android:textColorPrimary 12sp ?android:textColorSecondary true
  • suraj007suraj007 Member ✭✭✭
    ?attr/colorAccent ?attr/selectableItemBackground @style/MyCustomTabTextAppearance ?android:textColorPrimary 12sp ?android:textColorSecondary true
  • aga913aga913 Member ✭✭
    edited August 31

    Thank you very much for the fast respond.
    so you mean i should put this in styles.xml that contains a style and bind it from the Tabbar.axml right ?
    and yea i do see what do you mean its style and items
    for anyone how did not understand the code below
    this is how it should look like...

  • aga913aga913 Member ✭✭

    sorry to bother again but
    this:
    item name="fontFamily" AndroidAsset/MyRegularFont.ttf item
    or this:
    item name="android:fontFamily" AndroidAsset/MyRegularFont.ttf item
    and i don't know about the reference i used :/
    it's probably wrong so how do i reference to it ?
    if you have any link so i read more about it and you don't waste your time any further...

  • suraj007suraj007 Member ✭✭✭

    download fonts .ttf file which are used........
    https://www.fontsquirrel.com/fonts/list/popular

  • suraj007suraj007 Member ✭✭✭

    extract zip file and paste this file in asset folder.............

    Button button = FindViewById(Resource.Id.myButton);

    var font = Typeface.CreateFromAsset(Assets, "FontName.ttf");
    button.Typeface = font;

  • aga913aga913 Member ✭✭

    i meant

    here how do i implement my font i already have it in my Assets folder
    Sorry for troubling you and not being Clear enough

  • aga913aga913 Member ✭✭

    @suraj007 thanks a lot,
    in the last link you sent the important part says it's working in java
    "We’re setting our custom fonts in the java code. The MainActivity.java is given below"
    and it is a bit hard for me to use java since i have ~0 experience in java
    i asked the rest of my question in another thread
    thnx again ^_^

Sign In or Register to comment.