I have a ListView with header and I need to set header size programmatically depending on screen size. So it fills nearly whole screen. How can I do that? I found a way to get screen height, but it is the full height of the display, containing phone status bar height.
Asked
Active
Viewed 8,141 times
4
-
http://stackoverflow.com/questions/2394514/how-to-generate-a-listview-with-headers-above-some-sections – Haresh Chaudhary Sep 11 '12 at 08:08
-
is it looks like what i'm searching for? – Graykos Sep 11 '12 at 08:21
-
In that link,see the solved answer,that show how to generatye the custom header of the listview.There you can do the tamp to get you output. – Haresh Chaudhary Sep 11 '12 at 09:14
-
How can it help my needs? I know how to implement custom list rows and add header. I need to find out the size of notificationbar! – Graykos Sep 11 '12 at 09:40
1 Answers
6
if you are setting the header to the ListView by inflating a layout, like this:
ListView lv = getListView();
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false);
lv.addHeaderView(header, null, false);
you can change the height of the layout R.layout.header
using
header.setLayoutParams(params);
You can get Notification or Status Bar height using this code here:

Community
- 1
- 1

Archie.bpgc
- 23,812
- 38
- 150
- 226
-
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
. So I need to get notificationBarHeight, cause I suppose it could differ between different devices. – Graykos Sep 11 '12 at 08:35 -
so you got your screen height, and smthElse, all you need is notificationBarHeight? I mean what height you exactly want? – Archie.bpgc Sep 11 '12 at 08:36
-
yes, you may say I need notificationBarHeight. But I dont want to hardcode it, cause, I suppose, it may vary between different devices – Graykos Sep 11 '12 at 08:45
-