Rectangle 27 0

android Set listview header size programmatically?

ListView lv = getListView();
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false);
lv.addHeaderView(header, null, false);

You can get Notification or Status Bar height using this code here:

if you are setting the header to the ListView by inflating a layout, like this:

so you got your screen height, and smthElse, all you need is notificationBarHeight? I mean what height you exactly want?

the question is mostly not about setting the height, but about getting it. I can get the full height of the display (480x800 on my phone), but i need to set header height to <screenHeight - notificationBarHeight - smthElse>. So I need to get notificationBarHeight, cause I suppose it could differ between different devices.

yes, you may say I need notificationBarHeight. But I dont want to hardcode it, cause, I suppose, it may vary between different devices

you can change the height of the layout R.layout.header using