0

i am following this tutorial: http://www.androidhive.info/2012/02/android-using-external-fonts/

to apply custom japanese fonts to my android app programatically. How can i do this on xml and not programatically? Because i want to have a preview the font on elipse graphical layout.

Also, when i do this programatically, my text is not centered on the imageview. I do this to make it centered and it works if i don“t change the font:

`

        <ImageView
            android:id="@+id/karuta1_imageview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:src="@drawable/karutavaziatreinamento" />

        <TextView
            android:id="@+id/texto_karuta1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="@string/texto_karuta1"
            android:textStyle="bold"
            android:textSize="29sp"
              />
    </RelativeLayout>`

2 Answers2

1

I'm sorry but I'm quite sure that there is no way of doing this using only the XML code. You can only apply the built-in fonts via xml.

Here is another question which is similar to yours: Using a custom typeface in Android

Community
  • 1
  • 1
0

Use the android:fontFamily tag on each text view you wish to have that font.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127