Friday, February 27, 2015

Set textview style Programmatically in android

Setting the textview font size programatically is a simple procedure. For doing the same you can follow the below code:

Programmatically set text as bold,italic or underline :



 by Using Typefrace: textView.setTypeface(null, Typeface.BOLD_ITALIC);

textView.setTypeface(null, Typeface.BOLD);

textView.setTypeface(null, Typeface.ITALIC);

textView.setTypeface(null, Typeface.NORMAL);

by Using HTML tags:

String text = "Bolded text, italic text, even underlined!"

TextView tv = (TextView)findViewById(R.id.THE_TEXTVIEW_ID);

tv.setText(Html.fromHtml(text));

Hope the above code will work. Please let me know if you face any problem here. 

0 comments:

Post a Comment

Don't lose faith when you see others receive answers to their prayers

An elephant and a dog became pregnant at same time. Three months down the line the dog gave birth to six puppies. Six months later the dog...

 

G-Expo Template by Ipietoon Cute Blog Design