ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

Stacked tab navigation - view measurement issue

Open jgilfelt opened this issue 14 years ago • 7 comments

On pre ICS when I have 2 or 4 stacked tabs whose content width should not require scrolling within the tab container, there always seems to be a 1 pixel offset in the internal IcsLinearLayout which enables scrolling and the overscroll indicator. There is no problem when there are 3 tabs.

1 2

This is easily reproducable in the ABS sample app (Feature Toggles or Tab Navigation with 2 tabs).

3

jgilfelt avatar Oct 22 '12 12:10 jgilfelt

This probably due to the 1px divider we add. We don't modify the children's measurements at all. Le sigh.

JakeWharton avatar Oct 22 '12 16:10 JakeWharton

Thanks for the quick response. Why was it working on older builds which had the divider as well?

thunderousNinja avatar Oct 23 '12 02:10 thunderousNinja

This is probably my fault. The code doesn't account for margins when finding the largest child (getMeasuredWidth() doesn't include this when the measure phase is done, right?), whereas the framework does.

SimonVT avatar Oct 23 '12 20:10 SimonVT

For a quick fix I subtracted "n-1" (n being the number of tabs) in the useLargestChildHorizontal() call. Thought I'd share :+1:

thunderousNinja avatar Oct 30 '12 04:10 thunderousNinja

@Jon4thanGarcia That would only work on MDPI and HDPI devices since the divider is 2px wide on XHDPI.

JakeWharton avatar Oct 30 '12 04:10 JakeWharton

@JakeWharton Even if I put my own custom 1px divider?

thunderousNinja avatar Oct 30 '12 04:10 thunderousNinja

Jon4thanGarcia did it work with a 1px divider?

dbc1ever avatar Nov 02 '12 22:11 dbc1ever