I have a long text which I want to break into multiple pages. Also I need a way to style this text.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
UPDATE: I created sample application, that shows how to use PageSplitter.
How it works? Example application (Russian) - Cleverum. You need only
PageSplitter
class. Other code shows you how to use this class.First, you have to create
PageSplitter
object withpageWidth
andpageHeight
(in pixels) which you can get fromView.getWidth()
andView.getHeight()
:lineSpacingMultiplier
andlineSpacingExtra
must have same values aslineSpacingMultiplier
andlineSpacingExtra
attributes ofTextView
s which will keep page texts.Using
PageSplitter.append()
method you can appendtext
which will be measured withtextPaint
:Then by using
PageSplitter.getPages()
method you can get original text splitted to pages and put each of them intoTextView
:TextPagerAdapter:
PageFragment:
where
R.layout.page
isPageSplitter.renderToSpannable()
method wrapstext
toSpannableString
according totextPaint
settings. In current method implementation I consider onlyTextPaint.isFakeBoldText()
property, but you can also apply other properties. For example, you can applyTextPaint.getTextSize()
property withAbsoluteSizeSpan
.