How to change android keyboard key font?

后端 未结 4 758
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 16:42


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

4条回答
  •  爱一瞬间的悲伤
    2020-12-05 16:51

    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);
    key.setTypeface(myFont);
    

    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.

提交回复
热议问题