Pie
Pie

Reputation: 937

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 text because a text view just throws it all together and its just a big ugle block of words that no one can read. Any one know what to do?

Upvotes: 1

Views: 1110

Answers (3)

Broak
Broak

Reputation: 4187

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(new WebViewClient() {  
  @Override  
  public boolean shouldOverrideUrlLoading(WebView view, String url)  
  {  
    view.loadUrl(url);
    return true;
  }  
}); 
wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html");

demo_welcome.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Demo Html</title>
    <link rel="stylesheet" type="text/css" href="demo.css" />
  </head>
  <body>
    <H1>Testing One Two Three</H1>
    <a href="test.html">CLICK HERE</a><p>
    <a href="file:///android_asset/html_no_copy/test.html">OR HERE</a>
  </body>
</html>

test.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" type="text/css" href="test.css" />
    <title>Insert title here</title>
  </head>
  <body>
    <H1>TEST.HTML</H1>
  </body>
</html>

Upvotes: 1

wsanville
wsanville

Reputation: 37516

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.

Upvotes: 1

adamame
adamame

Reputation: 198

Use a webview. Then you can style your content as well.

http://developer.android.com/reference/android/webkit/WebView.html

Upvotes: 2

Related Questions