Android:动态设置ImageView?
|
我正在尝试下载图像,并动态创建ImageView并将其添加到我的布局中,但不会显示该图像。这是我的代码:
ImageView image = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
image.setLayoutParams(vp);
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.setImageDrawable(avatar);
theLayout.addView(image);
也许在添加ImageView之后需要刷新布局?您如何“刷新”?
没有找到相关结果
已邀请:
3 个回复
财沟项胶
变量中。
糕泰灌
淘圃跺枯替