Splitting a TextView into multiple TextViews relat

2019-04-12 12:32发布

问题:

So I have what I consider a rather complex problem. I have this massive TextView that is several screen lengths long. What I want to do is split the TextView up into smaller TextViews, each the height of the visible screen (So no vertical scrolling), and place the smaller TextViews in a horizontal-scrolling Gallery. I can do the latter no problem, but I can't think of a good way to break up the TextViews.

It's also worth noting the TextView contains many different styled text within it (different sizes, spacing, etc).

I'm not necessarily looking for solutions, but suggestions would be helpful and appreciated.

回答1:

You should take a look at AndroViews or android-viewflow. They provide the horizontal paging that you're talking about, with android-viewflow being backed by an adapter.

In terms of splitting up the TextView, you can subclass the onMeasure() and start figuring out sizes there. You could also look into seeing how FBReader does it, as it pretty much does exactly what you're talking about.