如何制作可以改变Android用户界面字体的应用程序?

Dre*_*per 8 java fonts android interface font-style

我想知道是否有人知道如何创建一个可以改变三星手机界面字体样式的应用程序.我有我喜欢的TrueType格式的字体样式.

Galaxy Apps商店有很多字体样式但它们是付费而不是我想要的.您可以看到应用程序作为示例安装用户后可以执行的操作只需转到设置>设备>字体样式>从列表中选择字体并更改字体样式.

我试过反编译它但没有得到太多.或者换句话说,翻转字体应用程序.

反编译源

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="1.1" package="com.monotype.android.font.presentltroman" platformBuildVersionCode="23" platformBuildVersionName="6.0-2438415">
    <uses-sdk android:minSdkVersion="7" />
    <application android:label="@string/app_name" android:icon="@drawable/icon">
        <provider android:name=".FontContentProvider" android:authorities="com.example.myfont" />
        <support-screens android:largeScreens="true" android:xlargeScreens="true" />
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

只有一项活动

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.FileNotFoundException;

public class FontContentProvider extends ContentProvider {
    private static final UriMatcher uriMatcher = new UriMatcher(-1);

    public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
        return null;
    }

    public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
        String file_name = uri.getPath();
        if (file_name == null) {
            throw new FileNotFoundException();
        }
        if (file_name.startsWith("/")) {
            file_name = file_name.substring(1);
        }
        AssetFileDescriptor ad = null;
        try {
            ad = getContext().getAssets().openFd(file_name);
        } catch (Exception e) {
            Log.v("CPFontTest", "cp - openAssetFile EXCEPTION");
        }
        return ad;
    }

    public int delete(Uri uri, String selection, String[] selectionArgs) {
        return 0;
    }

    public String getType(Uri uri) {
        AssetManager am = getContext().getAssets();
        StringBuilder xmlfileStringBuilder = new StringBuilder();
        try {
            for (String s : am.list("xml")) {
                xmlfileStringBuilder.append(s + "\n");
            }
            return xmlfileStringBuilder.toString();
        } catch (Exception e) {
            return null;
        }
    }

    public Uri insert(Uri uri, ContentValues values) {
        return null;
    }

    public boolean onCreate() {
        return true;
    }

    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        return null;
    }

    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        return 0;
    }

    static {
        uriMatcher.addURI(".fontcontentprovider", "fonts", 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试将它放在我的应用程序中,但它不起作用.

Mdl*_*dlc 2

虽然原生 Android 缺乏自定义系统字体的能力,但许多制造商已经调整了他们的软件来支持这一要求很高的功能,让您可以轻松更改 Android 字体

来源

这意味着您无法通过插件来使字体在所有 Android 设备上运行的系统 API。然而,个别制造商确实提供了自定义字体实现。

我对你进行了快速搜索,但似乎这些制造商不提供官方/通用 API(或像Samsung这样的模糊API)来更改其字体,相反,你必须单独查看每个制造商的主题/字体实现(逆向工程?),并了解如何设置系统范围的字体以及如何插入该系统。

如果您正在寻找根应用程序如何执行此操作的示例,有许多操纵字体的开源应用程序,例如