尝试更改字体Android Studio时出错 [英] Error trying to change font android studio

查看:86
本文介绍了尝试更改字体Android Studio时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在android studio中以编程方式更改TextView的字体,香港专业教育学院密切关注了一些教程,但它一直给我带来错误,只是想知道是否有人有任何想法?

I am trying to change the font of a TextView programatically in android studio, ive followed some tutorials closely but it keeps giving me errors and was just wondering if anyone has any ideas?

我遵循的问题示例:


  1. Android开发LCD字体

  2. 如何在TextView上更改字体?

  1. Android develop LCD font
  2. How to change the font on the TextView?

TextView:

TextView
android:id="@+id/settingsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:layout_marginLeft="60dp"/>

更改字体的代码:

Typeface myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/Stocky.ttf");
TextView settingsTitle = (TextView) findViewById(R.id.settingsTitle);
settingsTitle.setTypeface(myTypeface);

错误日志:

Function: selinux_android_load_priority [0], There is no sepolicy file
Function: selinux_android_load_priority [1], There is no sepolicy version file
Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9507_4.3_0016
selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts


推荐答案

它没有用,因为即使我实际上正在使用片段,我也在onCreate中执行代码部分,所以我只是删除了该片段并返回使用正常活动并且它现在可以正常工作。

It wasn't working because I was doing the code part in the onCreate, even though i was actually using fragments, so I just deleted the fragment and went back to using the normal activity and its working now.

感谢您的帮助。

这篇关于尝试更改字体Android Studio时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆