I have an activity configured with splitActionBarWhenNarrow that uses requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY).
And I need to check if screen is considered narrow to know if splitbar is visible because I have to change the position of one bottom component to don’t overlap with splitActionbar when visible.
PD: I know how to check orientation but I’m not sure if portrait is always equal to narrow
By checking the ActionBarSherlock sources I’ve found a solution that seems to work very well: Create a
values.xmlin yourvaluesresource directory and add a new boolean property like this:Then create a second
values.xmlin thevalues-w480dpdirectory:This second resource will automatically be loaded if the screen is wider than 480dp. In portrait mode your phone screen is smaller than that so
screen_is_narrowistruewhereas in landscape mode and on tablets it is wider and thusscreen_is_narrowbecomesfalse.Based on that logic you can simply do a check in your Activity code now:
That should do the trick. In case you’re already using ActionBarSherlock then there’s an even easier solution as the booleans have been predefined already. Simply check for
R.bool.abs__split_action_bar_is_narrowin your code.