paginate text and adjust its size - android

what I want is exactly what ThinkFree Office pdf viewer Reading View does.
I have a bunch of text and I want to be able to adjust it's size (users can choose from different zooms) and the text should paginate accordingly, I want it to wrap the screen, so that the user doesn't have to 'move' the screen, the rest of the text will show on the next page.
I know how pagination works, but how can I determine how much text has fitted the screen, so I know what to show on the next page?
Thank you

I mean't that you could adapt the codebase there by turning off the resizing part and just using it to paginate. It definitely would need work to make it fit this problem. Did you find a solution?

Related

Markaps in ImageView such as instagram have

I need to create the markups on image view that should look like the markings Instagram. The client should click on some position on the image, enter some text and save it.
For now, the only solution that I see is :
Get click position in the onToch event.
Dynamically put some edit boxes to this position.
Save the text and coordinates.
However, I don't know yet how this will work on different screen sizes.
Since I'm mostly web developer and definitely don't now all android capabilities I hope someone with experience will give me advice. Maybe there some widgets for this task, or algorithm for counting position?

make main view of app larger than the phone's screen

working on an app and The way I want to set it up is different than what I have ever done before. I want the main activity when launched into the app to exceed past the boundaries of the physical phone screen, and for the user to be able to swipe out to parts of the app that they can't originally see.
I am not sure what the terminology is or what methods or classes etc to use. Any info that could point me in the right direction would be great! Thanks!
Just some clarification:
I think what I'm trying to say is the second thing you talked about. Imagine if you place a iPhone for example in the middle of a piece of computer paper. What I want to achieve is to have the whole view the size of the paper, but only be able to see the size of the iPhone's screen at a time. So you can go up a little bit and see what was above the screen, or left or right
If you want more screens and be able to switch between them, use ViewPager.
If you want one large view bigger than screen, you can either combine ScrollView for vertical scrolling and HorizontalScrollView for horizontal scrolling, or make some custom View, which will be able to scroll (you have to implement it on your own) in both direction.
If you want to have just some views outside of the screen and bring them to visible area on some event, you can use RelativeLayout and set to its views proper margin.
If you want something else, add more information, how it should look and act like.

dynamically configuring views for a ViewPager widget?

First let me say that I'm very new to android development (although I have a good understanding of the basics of java), and I am building a magazine reader app for a campus publication I work for.
I want to display each article using a ViewPager widget. I'm going to build a java program which enables the magazine editor to post articles in .txt format onto a server, along with images associated with each, and have the android app periodically download these articles to a local folder.
I'm a little confused about how to construct the views for each ViewPager from the text files. Somehow my logic needs to determine the size of the screen running the app, in order to know how many words can fit on each screen.
Is this right, or am I fundamentally misunderstanding ViewPager somehow? If so, how might I structure the program to configure the views dynamically based on the txt + images given to it?
From what I understand, each page will contain as much of the article as possible, and when the user selects the article they will be able to see the entire thing. Something like this, but so it fills up the entire screen?
If this is the case, you have two options here:
Just ellipsize the textview so that it ends with a "..." at the end. Probably the preferred solution.
Resize the TextView to fit all your text (Auto Scale TextView Text to Fit within Bounds).
EDIT:
Here's a different interpretation of your question.
From what I understand, you're trying to have something like an eBook reader with an undefined number of pages; kind of what Flipboard does:
Basically, once all the text fills in the entire area you want to have it continue to the next page.
The easiest way to do this, if you do not need native performance, would be to just use a WebView, split the text across several columns, and have only one column be visible at a time.
However, it is certainly possible to calculate how tall the entire text would be and then split it up accordingly; i.e. Pagination in Android TextView
It seems similar questions have been asked and addressed: Splitting a TextView into multiple TextViews relative to screen height (see the accepted answer).

Android - how to display large text

I have a txt file which is around 2MB. I need to display it in android. I have tried out WebView and it takes around 5 seconds to load and display the file. Is there any way I can get it rendered faster? Moreover, I dont want to load all the text at the start. Something like a scrollbar which displays elements efficiently is what I require. I need not stick to WebView alone, but can choose to show it using any efficient way.
You can divide your text by paragraphs and use listview. show each paragraph of text in one item.

Present html content as dynamic "pages"

I'm building an e-Book reader for android. The content of an ebook is often divided into html files (epub) with one or may chapters in them.
I'm planning to build an e-book reader who divides the content of those files into different "pages". The problem is to know how many much text "fits" on one page and to calculate the correct amount of pages since that depends on a number of different factors, such as: font-size, word size, paragraphs, images, page-breaks, headlines etc.
Idealy i would have my text justified and selectable, and since that's not possible with normal TextView or EditText i must use a non-scrollable WebView.
So to sum it up, how can i "measure" how much text that fits on one "page" on my WebView? Or is there a different better approach to solve this? I saw that the Paint class as support for measure text and breakText.
Thanks!
Note : This answer does not use the webview as your display surface.
You can use the Canvas to draw each page. The canvas gives you it's height & width using which you can draw each line on the canvas using drawText based on the width & height available.
Basically you can calculate how many letters can fit in a line , take that many words , taking care you don't split any words and keep drawing the text.
If you break up the tasks to use different workers for each paragraph you can also probably make it fast.
Maybe you can do it like this
Text is being added and rendered inside WebView
In WebView, you can use Javascript to inspect the current state of DOM tree and extract measurements like width and height of individual elements
Javascript communicates back the size of the page back to WebView creator thru some callback
When Javascript detects that the page size threshold is exceeded it sends a signal for a page break needed
Android HTML5 Kindle does page breaking with Javascript so it is definitely possible.
Take a look at the source of FitText or perhaps here. Both figure how much text can fit in a given space. You may be able to borrow ideas from them and adapt for your purposes.

Categories

Resources