有時為瞭適配機型,我們需要動態更新組件的大小,為瞭達到在不同機型同樣的效果。
通過設置LayoutParams就可以達到這個效果。
[java]
ImageView pictureView = (ImageView) convertView.findViewById(R.id.picture_view);
ViewGroup.LayoutParams layoutParams=holder.picture.getLayoutParams();
layoutParams.width = 1024;
layoutParams.height = 768;
pictureView.setLayoutParams(layoutParams);
摘自 wxg630815