[Android Pro] listView和GridView的item设置的高度和宽度不起作用

referece to : http://blog.csdn.net/beibeixiao/article/details/9032569

1.     在Android开发中会发现,有时listView和GridView的item顶层布局不起作用,即不能设置高度和宽度

        原因是当用自定义的adapter时,如果使用convertView= mInflater.inflate(R.layout.material_grid_item, null)

方法就不会起作用,这个 方法的第二个参数是父View,传入为空,所以没有加载顶层布局,此时如果使用

convertView= mInflater.inflate(R.layout.material_grid_item, parent,false);传入parent设置的高度和宽度就会起作用了。

posted @ 2016-11-04 22:13  demoblog  阅读(3910)  评论(1编辑  收藏  举报