Android Display Lots Of Text
I have a recipe like page that has loads of text. Multiple lines of text that includes steps and all that. It's basical a recipe. Any way I need a way of displaying all this tex
Solution 1:
Use a webview. Then you can style your content as well.
http://developer.android.com/reference/android/webkit/WebView.html
Solution 2:
You can actually do quite a bit of formatting in a single TextView
using SpannableString and SpannableStringBuilder. It might not be your easiest solution, but it is really useful if you want to cut down on the number of views in your layout, or if you need to recycle views.
Here's a good example. It's easy to change text sizes, typefaces, text color, and more.
Solution 3:
Also consider using a Scroll view (if you of course use a control such as an Edit Text or TextView, I as well as Pie would recommend a webView, the only thing is generally i find it be wholly ascetically unpleasant.
WebView wv = (WebView)this.findViewById(R.id.splashWebView);
wv.setWebViewClient(newWebViewClient() {
@OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
returntrue;
}
});
wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html");
demo_welcome.html:
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"><title>Demo Html</title><linkrel="stylesheet"type="text/css"href="demo.css" /></head><body><H1>Testing One Two Three</H1><ahref="test.html">CLICK HERE</a><p><ahref="file:///android_asset/html_no_copy/test.html">OR HERE</a></body></html>
test.html:
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"><linkrel="stylesheet"type="text/css"href="test.css" /><title>Insert title here</title></head><body><H1>TEST.HTML</H1></body></html>
Post a Comment for "Android Display Lots Of Text"