7

Is there a way to get the width and height of an Options Menu in DPI (or any other measurement)?

comp sci balla
  • 823
  • 2
  • 13
  • 29

3 Answers3

3

As I understand - NO.

When you open option menu new Window created - specially for showing menu. And from activity(and it's window) there is not way to get some information about another windows.

For controlling layout you can try to find layout of menu window, and check how many dp it is.(all standart android layouts is in folder sdk_folder/platforms/platform-x/data/res/layout) But this is not the best way - it will be platform-dependent, and if for example HTC provide there own option menus - you will have problems.

Jin35
  • 8,602
  • 3
  • 32
  • 52
1

An android Menu object extends the View class, are the getHeight() en getWidth() methods not working?

In case they are working, but returning 0 every time, take a look at this question, where someone is encountering this problem when he wants to retrieve the width and height of a view.

Community
  • 1
  • 1
J. Maes
  • 6,862
  • 5
  • 27
  • 33
1

Here in the answer you can found a class that could be extended to a menu. And it will have the normally controlled and read width and height.

Community
  • 1
  • 1
Gangnus
  • 24,044
  • 16
  • 90
  • 149