how to use custom fonts in xamarin android

hi, i'm working on a project in xamarin android using visual studio 2015, how can i use custom fonts in the application. any response/article would be appreciated.

thanks

Best Answers

Answers

  • IsraelAshaIsraelAsha USMember ✭✭

    hi @RobertBruce, thanks for the solution. the first one worked flawlesly. however, i got an erros saying, Resource.Styleable doesn't contain a definition for CustomFonts. maybe is as a result of accessibility on my side. i created the attrs file and kept it in my Drawables folder. is that were it's supposed to be?

  • IsraelAshaIsraelAsha USMember ✭✭

    kk, i changed the folder of the attrs.xml to the resources/values folder and the error went away but after implementing the view, the text doesn't change dynamically

    here is what i tried

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cardview="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="wrap_content" cardview:cardBackgroundColor="@color/textcolor" cardview:cardCornerRadius="10dp" cardview:cardPreventCornerOverlap="false" cardview:cardUseCompatPadding="true" android:layout_gravity="center_horizontal"> <LinearLayout xmlns:foo="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp" android:layout_weight="20" android:id="@+id/quote" android:gravity="center"> <appiness.customFontsForTextView android:id="@+id/quoteText" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent" android:text="This is some random quote spoken by a true arabian" android:textColor="@color/grey" android:textSize="26sp" foo:customFont="fonts/fabfeltscript-bold.otf" android:layout_centerVertical="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> </LinearLayout> </android.support.v7.widget.CardView>
    my fonts re placed in the assets/fonts folder

  • IsraelAshaIsraelAsha USMember ✭✭

    hi @RobertBruce, pls did you see my last comment? i'm trying to style textboxes that i'm inflating inside a recyclerView and it isn't working
    pls give me any hint as to why. Thanks

Sign In or Register to comment.