自定义viewgroup 通过 LayoutInflater.from(context).inflate(R.layout.***, null) 生成的子布局width属性设置为match_parent之后,发现实际的效果并没有铺满全屏
原因是这个方法没有传入父布局,所以layout中的match_parent都失效了。
两种思路解决问题:
第一种方法 调整LayoutInflater的使用方法,传入父布局
View convertView = LayoutInflater.from(context).inflate(R.layout.***, parent, false);
第二种方法 调整layout中的父布局为RelativeLayout,再使用RelativeLayout的方法进行布局