Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dimension of soft buttons bar

Tags:

android

Is there a way to determine the dimension (width) of the menu bar of devices without hard menu buttons? (like the archos devices).

I need to know the usable dimension of the screen...

like image 593
Direz Gunstad Avatar asked Dec 31 '11 16:12

Direz Gunstad


1 Answers

A very late answer but for anyone that encounters this problem. A simple way to get the amount of usable space offsetting any soft keys/navigation bar or even the status bar, is to use getWindowVisibleDisplayFrame(Rect) from the Apps DecorView. This will load a Rect object with the dimension of the display that is actually usable.

Since you cannot directly get a reference to the Activiy's DecorView, you need to first get the Activity's window using the accessor method, getWindow(). This will return the window object that holds the Activity and other screen elements. To get the decorView that contains the activity as well as the screen decorations i.e. the status bar, navigation bar/soft button bar, call accessor method getDecorView(). Once your have a reference to the DecorView call getWindowVisibleDisplayFrame(Rect) and you will have a loaded Rect object.

like image 139
cincy_anddeveloper Avatar answered Oct 21 '22 07:10

cincy_anddeveloper