Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Width and height of an Options Menu?

Tags:

android

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

like image 459
comp sci balla Avatar asked Jan 11 '12 20:01

comp sci balla


2 Answers

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.

like image 74
Jin35 Avatar answered Sep 28 '22 14:09

Jin35


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.

like image 23
J. Maes Avatar answered Sep 28 '22 13:09

J. Maes