Reputation: 823
Is there a way to get the width and height of an Options Menu
in DPI (or any other measurement)?
Upvotes: 7
Views: 5919
Reputation: 8612
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.
Upvotes: 3
Reputation: 24464
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.
Upvotes: 1
Reputation: 6892
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.
Upvotes: 1