我无法在属性中添加字体文件:
android:font="@font/Roboto-Regular"
我已经遵循了一些教程,但是我做到了:
在res中创建了名为font的文件夹
将我的ttf字体文件复制粘贴到其中
创建的字体资源文件
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<font
android:font="@font/Roboto-Regular"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/Roboto-Regular"
app:fontStyle="normal"
app:fontWeight="400"
tools:ignore="UnusedAttribute" />
</font-family>
答案 0 :(得分:0)
对我来说,更简单的解决方法是打开我的layout.xml
并在属性中选择字体系列。这样,您可以安装Google字体,该字体会自动在/res
中创建字体文件夹。
此外,我相信它的android:fontFamily="@font/Roboto-Regular"
语法。