Question

I am a noob. I've seen some of the solutions here, and that just bounced above my head. Can anyone please help me setting up a font in the button? Also, if I can make it italic, bold etc. Here's my XML code

  <Button
    android:id="@+id/button1"
    android:layout_width="60dp"
    android:layout_height="40dp"
    android:layout_alignBottom="@+id/tableLayout1"
    android:layout_alignRight="@+id/relativeLayout1"
    android:background="@drawable/crea"
    android:textSize="30sp"
    android:textColor="#ff0000"/>

No correct solution

OTHER TIPS

You cannot use comic sans MS without purchasing a license:

https://docs.microsoft.com/en-us/typography/font-redistribution-licensing

There are free similar fonts available:

https://fontlibrary.org/en/font/comic-relief

Basic operation in using a different font is to add the font file to the assets folder in the project then use setTypeface on the widget:

Typeface font = Typeface.createFromAsset(getAssets(), "ComicRelief.ttf");
Button bt=(Button) findViewById(R.id.button0);
bt.setTypeface(font);

Full info on using fonts here:

https://tekeye.uk/android/examples/android-textview-edittext-font

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top