1

I need to display a Terms and Conditions pdf in a layout. It is not essential for the actual PDF to be displayed. That is, I just need the text within the pdf to be displayed correctly, in paragraphs.

Using TextViews seems like the obvious option; however, I feel like both copy pasting each paragraph into a different TextView or copy-pasting it all into one and writing out the \n escape sequence after every paragraph will take too long (it is a very long document)... not to mention I will have to manually put in html tags for all the bold words.

So how can I display a large amount of text in a layout without having to manually hardcode all of the paragraphs? I thought there would be some support to display a pdf, but after some research it looks like that that's not possible if the user's device doesn't have a pdf reader installed?

u3l
  • 3,342
  • 4
  • 34
  • 51
  • If you have a `Text Content` with some `Text Style(Bold,Italic,...)` then i would suggest you create `HTML` page and load this page with `CSS` from `Assets` to your `WebView`. – M D May 30 '14 at 05:52
  • I tried this with a webpage in my assets folder (more specifically, I tried implementing what the accepted answer mentions here: http://stackoverflow.com/questions/14767892/web-view-is-not-loading-local-html-file-in-android), but my layout comes up blank for some reason. Could you perhaps elaborate on how to do this? – u3l May 30 '14 at 06:20
  • 1
    but if you recently add `HTML` page and `CSS` in your `Assets` then you must uninstall your app and install again a fresh built apk. – M D May 30 '14 at 06:22
  • Thank you! You were right, I just had to uninstall first and now it works perfectly. – u3l May 30 '14 at 07:54

2 Answers2

0

I think a multiline scrollable textview will do the job for you. You can set the size of the text view to be fixed, say half your screen if you want, and the user can scroll in just this portion. See Making TextView scrollable on Android

Community
  • 1
  • 1
Kartik_Koro
  • 1,277
  • 1
  • 11
  • 23
  • I am aware of how to scroll through the text, that's not my problem. I need to figure out how to enter all the text correctly such that all the paragraphs and formatting display correctly. – u3l May 30 '14 at 06:19
0

You can use a PDF library to display the file in the screen without having to manually reading and displaying it. I never used any, but here's one you can try:

Android-Pdf-Viewer-Library