LinearLayout linear = (LinearLayout) findViewById(R.id.ll_group);
private void addImage(int size){
linear.removeAllViews();
for (int i = 0; i < 20; i++) {
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); //设置图片宽高
imageView.setImageResource(R.drawable.ic_launcher); //图片资源
linear.addView(imageView); //动态添加图片
}
}
动态添加图片
最新推荐文章于 2023-03-29 14:51:32 发布