Split html string into multiple pages

前端 未结 2 1206
天命终不由人
天命终不由人 2020-12-31 07:32

I am trying to develop eBook reader kind of android application. I need to split long html string(sent by server at run-time) into pages on fly based on the screen space ava

2条回答
  •  心在旅途
    2020-12-31 08:12

    You have to parse the HTML, best would be to use some library where you can access the DOM like in JavaScript. Then you can create a custom layout for the parsed content. Does WebView supports JavaScript? That would be a good start to try with.

    Obviously you can not split at arbitrary locations of the HTML file, your have to consider the HTML-Tags. After modifying the DOM or splitting the html you can provide an custom CSS file for the content to display it in a way you like and add some pagination using your library or JavaScript.

    Using can help you to hide content in a website. Then you don't have to split is physically (it is in memory after loading the page anyway).

    Hope that helped a bit. You will not get a full solution here, but maybe you got some ideas. If you find further more specific problems it will be easier to ask more specific questions.

提交回复
热议问题