import java.lang.reflect.Field; import android.content.Context; import android.graphics.Typeface; public final class FontsOverride { public static void setDefaultFont(Context context, String staticTypefaceFieldName, String fontAssetName) { final Typeface regular = Typeface.createFromAsset(context.getAssets(), fontAssetName); replaceFont(staticTypefaceFieldName, regular); } protected static void replaceFont(String staticTypefaceFieldName, final Typeface newTypeface) { try { final Field staticField = Typeface.class .getDeclaredField(staticTypefaceFieldName); staticField.setAccessible(true); staticField.set(null, newTypeface); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } }
add this class to your code.
public final class Application extends android.app.Application { @Override public void onCreate() { super.onCreate(); FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/GeezEdit.ttf"); FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/GeezEdit.ttf"); } }
..... here you can see some fonts / fontname added. These are external font files that you can use to override your look / keyboard labels.
Add this application name to the application name of the Android manifest file.
Example
<application android:name=".Application" android:allowBackup="false" android:installLocation="internalOnly" android:label="@string/ime_name" android:theme="@style/AppTheme" >.......
Now update the above font name in your style. The base theme or theme that you use in your manifest application.
Example
<style name="AppTheme" parent="AppBaseTheme"> <item name="android:typeface">monospace</item> </style>
Ankush bist
source share