Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Different Font Styles in TextView

Tags:

java

file

android

I can display the contents of a file in a TextView by adding the file under the raw folder and reading the file. It works fine. But all of the contents in the file look the same. I want to differentiate titles and the contents by introducing Font styles. Can anybody help?

like image 917
Kakey Avatar asked Feb 24 '23 03:02

Kakey


2 Answers

What I understood from your question is that you want to apply different formatting to different parts of your text in TextView. But As I know, TextView doesn't supports multiple styles (formatting) (yet). Whatever the formatting you apply, will be applied to the whole text in TextView. To use different formatting, you can use the WebView.

Update:

This functionality is available for EditText (I saw it too late), see this link for details; http://developer.android.com/resources/faq/commontasks.html#selectingtext

like image 195
Mudassir Avatar answered Mar 04 '23 21:03

Mudassir


You can use WebView instead as your text is static you can format it to create a htmlPage and then display it in webview something like this

WebView mView = (WebView) findViewById(R.id.help_text);
mView.loadUrl("file:///android_asset/help.html");
mView.getSettings().setSupportZoom(false);
like image 28
ingsaurabh Avatar answered Mar 04 '23 22:03

ingsaurabh