0

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?

Examples of questions I followed:

  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"/>

Code that changes font:

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

Error log:

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
Community
  • 1
  • 1
Brenton
  • 49
  • 6
  • The lines you have posted that is your "error log" has nothing to do with your app. Please explain what "keeps giving me errors" means. – CommonsWare Jul 28 '15 at 12:41
  • where you have placed font files? – Mohd Mufiz Jul 28 '15 at 12:42
  • the logcat spits out those errors, im sorry if they are not relevant I wasn't sure, also my font file is in an assets folder that is in src/main – Brenton Jul 28 '15 at 12:45
  • Also by keep giving me errors, I mean the entire activity wont load, it just goes to a black screen, at the moment that TextView is the only thing in the activity so it cant really be much else causing this. – Brenton Jul 28 '15 at 12:47
  • have you set content view of your activity and also try to set textColor white to your textview – Mohd Mufiz Jul 28 '15 at 12:47
  • Run in on non-selinux device and tell – DevUt Jul 28 '15 at 13:12
  • Post the correct log cat error , re run your activity and when it crash choose error in logcat and post all the red lines – Sanjeev Jul 28 '15 at 13:31

1 Answers1

0

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.

thanks for the help.

Brenton
  • 49
  • 6