安卓中使用ttf字体文件

官方文档中提供的方法要设备能访问google?

官方方法

直接下载字体的fft文件

我要使用的是lexend

需要的格式可以在里面搜索

使用下载的ttf文件

解压出来

可以单独使用static里面的,里面是直接的lexend的各种格式

但是我这里直接使用Lexend-VariableFont_wght.ttf

说明文件写了这里面包含所有格式

将ttf文件放到res/font目录下,然后分别对需要使用的不同类型的格式创建单独的文件

文件中可以自定义style,我这里就是定义了字体粗细android:fontWeight

现在可以在布局文件中使用该font了

看看最终效果

相关推荐
梦想三三15 分钟前
LangChain Output Parser 实战:从字符串到结构化数据的完整指南
android·服务器·langchain·github·uv
爱笑鱼2 小时前
Binder(八):远端进程死了,BinderProxy 为什么还能收到通知?
android
Android-Flutter3 小时前
Kotlin 冷流与热流详解
android·kotlin
zhangphil3 小时前
Android ContentProvider/ContentResolver读图片,跨进程 IPC慢
android
yueqc13 小时前
Android .so 文件压缩
android·so·包体积
龚礼鹏4 小时前
深入解析 Android Automotive (AAOS) 启动流程与 CarService 核心机制(基于 Android 16 最新源码视角)
android
rosmis4 小时前
agent各指标定义
android·java·开发语言
风样滴男人哟5 小时前
PHP特性之反射类ReflectionClass机制
android·开发语言·php
小孔龙6 小时前
RenderNode 与 DisplayList:Android 硬件加速的绘制记录与复用
android·性能优化
qizayaoshuap6 小时前
鸿蒙 ArkTS 实战:搜索列表 城市实时过滤(示例 94)
android·华为·harmonyos