开发者社区 问答 正文

问下 EMAS中Android 的流水线 如何去配置字体呀? 我这边的gradle 的脚本里面有涉及

问下 EMAS中Android 的流水线 如何去配置字体呀? 我这边的gradle 的脚本里面有涉及到字体的逻辑?

展开
收起
真的很搞笑 2023-06-05 17:48:28 101 分享 版权
1 条回答
写回答
取消 提交回答
  • EMAS中Android的字体配置可以通过gradle脚本实现。首先需要在gradle的dependencies中加入字体库的引用,例如:

    dependencies {
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.github.bumptech.glide:glide:4.9.0'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'com.tencent.mm:emastext:1.0.0'
    }
    

    其中,com.tencent.mm:emastext:1.0.0是EMAS提供的字体库。

    接着在res目录下创建一个fonts目录,并将字体文件放在该目录下,例如:

    res/
      fonts/
        font1.ttf
        font2.ttf
    

    最后在xml布局文件或代码中设置字体即可,例如:

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:fontFamily="@font/font1" />
    

    其中,@font/font1表示引用res目录下的fonts目录中的font1.ttf字体文件。

    2023-06-06 09:20:57
    赞同 展开评论