我被困在一個奇怪的場景,而開發Android應用程序。動態加載圖像
我的應用程序,從互聯網下載圖像並在應用程序中以縮略圖格式填充它。
由於我不知道在設計時圖片/縮略圖的數量,我使用下面提到的代碼動態創建圖像視圖控件。
ArrayList<String> parsedPhoto=oPhotoList.getPhoto();
RelativeLayout media = (RelativeLayout)findViewById(R.id.media);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
for(int iCounter=0;iCounter<parsedPhoto.size();iCounter++)
{
bitmap=oParser.DownloadImage(parsedPhoto.get(iCounter));
ImageView img = new ImageView(this);
img.setImageBitmap(bitmap);
media.addView(img,p);
}
但在這種情況下,我所有的圖像都會相互重疊。 其中我想要3個圖像顯示在每一行,我可以通過XML來實現。
有人可以幫我。