Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect position of notifications area?

Tags:

android

Is there a way to detect programmatically whether the notification area is located at the top of the screen or in the bottom right corner (like on most tablets) ?

like image 899
sdabet Avatar asked Dec 21 '12 15:12

sdabet


1 Answers

Notifications are always shown in a 25dp-tall status bar at the top of the display, except for sw600 devices (that is, the smallest width in any orientation is 600dp; see this blog post for more info) on API levels 11 (Honeycomb) through 16 (Jelly Bean pre-MR1). On those devices there is a 48dp-tall "combined system bar" at the bottom of the display.

The easiest way to check for this is via qualified resources; that is, put your top-status-bar-assuming layout in layout/foo.xml, but then have a bottom-system-bar version in layout-sw600dp/foo.xml. Finally, since these large devices now use the top status bar as of Android 4.2 (API 17) you'll need to switch back to the top-status-bar version in layout-sw600dp-v17/foo.xml.

If you just want a boolean value that will tell you whether the status bar is at the top, replace layout in the above example with values, and place a <bool> into foo.xml that is true except in the values-sw600dp case.

like image 156
dsandler Avatar answered Sep 28 '22 00:09

dsandler