1

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?

Pie
  • 856
  • 4
  • 12
  • 33
  • look at this: http://stackoverflow.com/questions/4235890/recommended-approach-for-presenting-formatted-text-in-android – uday May 30 '12 at 21:46

3 Answers3

2

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

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

adamame
  • 188
  • 11
  • Does that mean I can make a page out of html or something? I'm new here with all this so is there a tuturial or something cause I don't have a website or anything with that on it I'm wondering if I can put a html page in the app that it loads or something. – Pie May 30 '12 at 22:31
  • Yep, a webview loads an html page. You can load a webpage right in the app on a webview, or you can build up the html content yourself. Here's Android's webview tutorial: http://developer.android.com/resources/tutorials/views/hello-webview.html – adamame May 31 '12 at 22:47
1

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.

wsanville
  • 37,158
  • 8
  • 76
  • 101
1

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>
Broak
  • 4,161
  • 4
  • 31
  • 54
  • Does that mean I can make a page out of html or something? I'm new here with all this so is there a tuturial or something cause I don't have a website or anything with that on it I'm wondering if I can put a html page in the app that it loads or something. – Pie May 30 '12 at 22:40