3

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.

Jason Robinson
  • 31,005
  • 19
  • 77
  • 131

1 Answers1

2

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.

Steve Pomeroy
  • 10,071
  • 6
  • 34
  • 37
  • Actually, AndroViews may not entirely be the right fit. It can't be backed by an adapter, so you have to create and populate all the views yourself. – Steve Pomeroy Jun 07 '11 at 20:21
  • I appreciate the response, but it seems like the libraries you've linked just create a horizontal scrolling view, but don't handle when the size of one item exceeds the length of the screen, which is what I need. I basically need to pass in just one View and have an Adapter split it up into horizontal views. – Jason Robinson Jun 07 '11 at 20:52
  • Sure. Part of what I'm suggesting here is that you create a custom TextView and a custom adapter that work together to split up your content the way you want it. You can override onMeasure() to measure the height of the text using various Paint text measuring methods. When it exceeds your boundary, have it communicate to your adapter to add another virtual "page". You probably just need to render ±1 page in order to handle sizing for page flipping. – Steve Pomeroy Jun 08 '11 at 02:00