The idea of Android Reader (i)

Source: Internet
Author: User

Recent work in business has met the needs of Android readers. The first question is how to divide a novel into content that needs to be displayed on each page, depending on the size of the screen. To put it simply, the string of a whole novel becomes a string["string that is exactly what each page can display."

First, we want to get the wide-height--width,height of the display area.

Then, the number of rows that can be displayed on a screen rowcount the current font size is calculated.

Next, set the font size, alignment

        New Paint (paint.anti_alias_flag);        Mpaint.settextalign (Paint.Align.LEFT);        Mpaint.settextsize (14);

Next, remove the first paragraph:

        int paragraphend = str.indexof ("\ n")        ; = str.substring (0, Paragraphend);

And get the first line to show how many words:

        int true NULL );        LOG.D ("tag", "The End index is =====" + breakindex);         = Str.substring (Breakindex);

If this paragraph is finished, remove the paragraph; If this page ends and the paragraphs are still not displayed, the remaining strings will be spelled back to the original content for display.

This completes the basic idea of a reader page display.

Done.

  

  

  

The idea of Android Reader (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.