Home » Android » How to change android keyboard key font?

How to change android keyboard key font?

Posted by: admin June 15, 2020 Leave a comment


How can I change the default font for keys of keyboard I am writing in android (Eclipse)?
Thank you

How to&Answers:

One solution is to use keboardView.java instead of android.inputmethodservice.KeyboardView.

You also need to change paint.setTypeface(Typeface.DEFAULT_BOLD) to paint.setTypeface(my font) and you must add attrs.xml to your project.


I found an answer : Implemented onDraw…

public void onDraw(Canvas canvas) {
    }catch(Exception ex){

    if (mBuffer!=null)
        canvas.drawBitmap(mBuffer, 0, 0, null);


if you are thinking to change the font style of android custom keyboard keys font style with an external .ttf font style then you can check my answer at a link
answer to change the font style of key label of android custom keyboard and also to change the font style throughout the android application

this answer is verified by me personally so you can trust and check this.


Well that’s a very broad question. I can tell you how to set a different Typeface; how you work that into your keyboard application is up to you.

Place a font (.ttf or .otf) into your assets folder, and use the following code (assuming a font called “myfont.ttf” and a TextView with an id of “key”):

Typeface myFont = Typeface.createFromAsset(getAssets(), "myfont.ttf");
TextView key = (TextView)findViewById(R.id.key);

Reminder: Don’t forget to check the license for the font you are using. Most do not allow redistribution without compensation. One freely licensed font you can use is Bitstream Vera Sans.