java - android: font family for whole app -


i don't want use default font app.

i want use desired font.

therefore, copied desired font in assets/fonts/ folder , coded shown below.

however, error occurs.

please me use same font full app.

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     linearlayout ll = new linearlayout(this);     ll.setbackgroundresource(r.drawable.bg);     this.setcontentview(ll);     textview tv = (textview) findviewbyid(r.id.app_name);     typeface face = typeface.createfromasset(getassets(),                     "fonts/tau_madn.ttf");     tv.settypeface(face); 

update:

my xml textview code;

  <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="app_name"         android:textstyle="bold" /> 

error:

error: error: string types not allowed (at 'id' value 'app_name').

your error has nothing loading of custom font asset.

in layout r.layout.activity_main there no textview id: r.id.app_name, therefore when initialize textview in code error thrown.

make sure have such textview in layout.

if think do have textview in layout already, try , clean project.

edit

add id below:

android:id="@+id/app_name" 

also rename font lowercased ".ttf" extension, , reference same.

typeface face = typeface.createfromasset(getassets(),                     "fonts/tau_madn.ttf"); // lowercased ".ttf" reference 

see here more info on issue.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -