i have developed android app few months ago targets api 19 , compiled api 19. 1 of things did changed font of action bar title , color dynamically based on scrolling , other factors. have used method below:
// change font of action bar int titleid = getresources().getidentifier("action_bar_title", "id", "android"); textview abtitle = (textview) findviewbyid(titleid); typeface typeface = typeface.createfromasset(getassets(), "fonts/lato-regular.ttf"); abtitle.settypeface(typeface); //this part dynamic based on calculation of ratio abtitle.settextcolor(getresources().getcolor(r.color.white)); abtitle.setalpha(ratio); now have switched material desing , have used appcompat v7: 22+. when run application crashes , gives me nullpointerexception in following line:
abtitle.settypeface(typeface); so seems gets id of title cannot find textview
any idea or other ways achieve more appreciated.
Comments
Post a Comment