Header View height in a ListView

后端 未结 1 1458
忘了有多久
忘了有多久 2021-02-19 03:59

I\'m working with a ListView that is part of an ListFragment. I want to add a header with a specific/custom height but it does not matter what I put in the height of the header

相关标签:
1条回答
  • 2021-02-19 04:23

    When you pass in null as the second parameter to inflate(), you are saying there is no parent associated with the view. This has the unfortunate side effect where any layout_ attribute you use is ignored as layout_ parameters affect how the parent lays out the child view rather than directly affect the child (like other views): this pro-tip godes into more details on layout_ attributes.

    You can use inflate(R.layout.header, getListView(), false) to pass in the ListView which will eventually the parent of your header view (note the false says to not add the view directly - ListView will do this automatically for you).

    0 讨论(0)
提交回复
热议问题