android - Change font of entire application -



android - Change font of entire application -

this question has reply here:

custom fonts , custom textview on android 3 answers how set default font family entire android app 5 answers

i want utilize custom font in application. best way give font entire application. know how assign custom font single textview or button.

is possible mention custom font in 1 place, eg. in styles.xml, , font applied whole application (every textview, button, edittext , soon).

use type of textview in app

public class mytextview extends textview { public mytextview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); init(); } public mytextview(context context, attributeset attrs) { super(context, attrs); init(); } public mytextview(context context) { super(context); init(); } public void init() { typeface tf = typeface.createfromasset(getcontext().getassets(), "font/chiller.ttf"); settypeface(tf ,1); } }

also edit text

public class cedittext extends edittext { private context context; private attributeset attrs; private int defstyle; public cedittext(context context) { super(context); this.context=context; init(); } public cedittext(context context, attributeset attrs) { super(context, attrs); this.context=context; this.attrs=attrs; init(); } public cedittext(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); this.context=context; this.attrs=attrs; this.defstyle=defstyle; init(); } private void init() { typeface font=typeface.createfromasset(getcontext().getassets(), "fonts/myfont.ttf"); this.settypeface(font); } @override public void settypeface(typeface tf, int style) { tf=typeface.createfromasset(getcontext().getassets(), "fonts/myfont.ttf"); super.settypeface(tf, style); } @override public void settypeface(typeface tf) { tf=typeface.createfromasset(getcontext().getassets(), "fonts/myfont.ttf"); super.settypeface(tf); }

android fonts styles custom-font

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -