久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我可以更改 Android 自定義鍵盤的輸出字體嗎?

Can I change the output font of an Android custom keyboard?(我可以更改 Android 自定義鍵盤的輸出字體嗎?)
本文介紹了我可以更改 Android 自定義鍵盤的輸出字體嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我開發了一個 android 自定義鍵盤.我需要更改實際使用 unicode 打印的輸出文本的字體樣式.

I have developed an android custom keyboard. I need to change the font style of my output text which are actually printed using the unicodes.

如何在不更改設備默認字體的情況下更改設備中任何位置的鍵盤文本輸出的字體樣式?

How can I change the font style of my keyboard's text output anywhere throughout the device without having to change the device's default font?

字體也不在安卓設備中,所以我們必須從開發鍵盤的同一個應用程序外部提供字體.

The font is also not in android device, so we have to privide the font externally from the same application which is developing the keyboard.

推薦答案

更改應用程序內的字體樣式.

changing the font style inside the application.

創建一個名為

字體覆蓋

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();
    }
    }
}

現在創建另一個類來覆蓋名為

now create another class to override the fonts named

應用

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");
        /*FontsOverride.setDefaultFont(this, "MONOSPACE", "MyFontAsset2.ttf");
        FontsOverride.setDefaultFont(this, "SERIF", "MyFontAsset3.ttf");
        FontsOverride.setDefaultFont(this, "SANS_SERIF", "MyFontAsset4.ttf");*/
    }
}

現在將此字體添加到值文件夾中的 android 樣式文件中的樣式

now add this typeface to style in android style file at values folder

<item name="android:typeface">monospace</item>

最后在應用標簽內的android Manifest文件中提到應用名稱

At last mention the Application name at android Manifest file inside application tag

android:name=".Application"

這將有助于將用戶提供的字體更改為 android 項目或應用程序.

This will work to change the user provided font to the android project or application.

這篇關于我可以更改 Android 自定義鍵盤的輸出字體嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 国产精品亚洲一区二区三区在线 | 中文字字幕一区二区三区四区五区 | 国产成人网 | 99久久99| 久久久久av| 久久精品欧美一区二区三区不卡 | 亚洲精品视频免费 | 黄a在线观看 | 国产一区免费 | 欧美一区免费 | 欧美成人h版在线观看 | 国产偷久久一级精品60部 | 91精品国产一区二区三区动漫 | 国产精品久久久久久二区 | 国产精品久久久久久久久免费软件 | 久久久.com | 久久99精品久久久久久青青日本 | 国产一区在线免费观看视频 | 久久国产精品免费一区二区三区 | 国产精品久久久久久 | 美女天堂在线 | 97狠狠干 | 亚洲最大av网站 | 99re视频这里只有精品 | 免费毛片在线 | 最新国产精品 | 亚洲三区在线观看 | 成年无码av片在线 | 国产成人午夜电影网 | 婷婷不卡| 欧美亚洲第一区 | 国产精品二区三区在线观看 | 一级女毛片 | 久久精品影视 | 国产视频在线一区二区 | 大学生a级毛片免费视频 | 亚洲精品乱码久久久久久按摩观 | 日韩色在线 | 在线播放国产一区二区三区 | 在线观看免费黄色片 | 蜜桃av鲁一鲁一鲁一鲁 |