Is there any possibility to load html from res/raw into the TextView? I know I can use WebView, but damn transparency is not always working (not on every device)
myTextView.setText(Html.fromHtml(readTxt()));
//This function will return string which you can set in your textview. And that String have html codes so use Html.fromHtml
private String readTxt() {
InputStream inputStream = getResources().openRawResource(R.raw.My_html_file);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
try {
i = inputStream.read();
while (i != -1) {
byteArrayOutputStream.write(i);
i = inputStream.read();
}
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return byteArrayOutputStream.toString();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With