views:

219

answers:

1

I have a TabView and on its first tab I have a ViewFlipper displaying two pages of ImageButtons (say buttonsPage1 and buttonsPage2).

When in landscape orientation, I need the image buttons pages to be scrollable, so I tried to add a ScrollView on buttonsPage1 and another on buttonsPage2. I get a StackOverflowError.

I tried then to suppress the ScrollView from the pageButtons1 and 2 and to include the ViewFlipper in a ScrollView. I got the same StackOverflowError.

If I completely remove the ViewFlipper, the applications runs as expected, no error occurs, only I DO need the scrolling when in landscape orientation.

Can anybody, please, give me hand to solve this issue?

A: 

I get a StackOverflowError.

If your stack trace lists a whole bunch of internal Android methods that seem to be related to drawing your UI, then your UI is too complicated. Use hierarchyviewer and your emulator to view the View/ViewGroup tree for your activity, and find ways to remove layers. For example, if your TabWidget does not hold a ViewFlipper, but rather you use an Intent to designate an activity that goes in the tab, that adds several layers to your View hierarchy more than just using Views as the contents of tabs.

My general rule of thumb is to try to keep my view hierarchies to single digit depth, as measured from the root through the longest branch. By the time you get to 15 layers, you are almost assuredly going to crash somewhere.

If your StackOverflow error does not seem to be related to drawing your UI, though, you need to post the stack trace as an edit to this question.

CommonsWare
Thank you, it was indeed a matter of complexity. HierachyViewer is priceless.
Manu