android viewpager包含分隔到页面的长文本 [英] android viewpager to contain a long text separated to pages

查看:79
本文介绍了android viewpager包含分隔到页面的长文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个viewPager.我想在viewPager中放置一长段文本.我不希望文本是可滚动的,我希望将其分隔或分割为多个页面,并且当用户页面显示时,它会在其他页面中显示其余文本.

I have a viewPager in my app. I want to put a long block of text in the viewPager. I don't want the text to be scrollable, I want it to be separated or parted to pages, and when the user pages it shows the rest of text in the other pages.

我该如何处理?

推荐答案

Android使用(Boring | Static | Dynamic)Layout类来测量和包装文本,这些类将width作为构造函数参数,并将计算文本的总高度,它们还提供了诸如getLineHeight(int line)之类的方法来获取行信息,因此您可以根据这些信息来计算String偏移量.我创建了一个类来执行此操作,请在此处查看我的答案: https://stackoverflow.com/a/30468884/2800351

Android use (Boring|Static|Dynamic)Layout classes to measure and wrap text, Theses class take width as constructor param and will calc the total height of you text, they also provide methods like getLineHeight(int line) to get line info, so you can calculate String offset according to these info. I create a class to do this, see my answer here: https://stackoverflow.com/a/30468884/2800351

这篇关于android viewpager包含分隔到页面的长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆