Cell Menu Screen Size

Hi, I'm trying to get the screen size minus the menu bar at the bottom.

I know that I can just subtract a constant number according to the resolution of the device, but it's a super ugly hack. I am sure that Google people are not so stupid as to forget to give the user a function to get the height of the bottom menu bar so that I can subtract it from the full screen size

This is a similar post. Android notification bar size and title bar?

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

what_i_need =metrics.heightPixels-buttomMenuHeight();

I need buttomMenuHeight ();

I could not find it in the API. I really don't care about backward comparability at the moment

thank

+3
source share
3 answers

? LinearLayout , , .

, , , , Android, Google TV, - .

+7

getHeight() onLayout. .

EDIT: , Activity onLayout, onSizeChanged.

( , ?)

+1

I draw the image in my own code, and I need to pass the screen size to C.

I tried to get the height using the getHeight () view, but returns 0 always even after calling setContentView.

RelativeLayout masterLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
masterLayout.setLayoutParams(params);
setContentView(masterLayout);

when I try masterLayout.getHeight (), it returns 0. I expected to get the full height of the screen, as I said fill_parent.

0
source

Source: https://habr.com/ru/post/1795873/


All Articles