Height of ListView fills the whole screen, although set as wrap_content

允我心安 提交于 2019-12-01 03:34:53

You shouldn't use wrap_content for the height of a ListView. wrap_content means "make me as large as needed to hold all of my children." When you consider that your data set could be potentially very large, that should sound like a pretty bad idea. Since you are using a LinearLayout, give your ListView layout_height="0dp" and layout_weight="1".

It's okay to let the ListView take the remainder of the screen. If it only has one row, it will show one row, no big deal. Unless you are trying to show something below the list, but what I've told you above should accomplish that.

Calvin Park

If above doesn't work, you can just use RelativeLayout instead of linear and put the ListView underneath the EditText.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!