我目前的尝试:

            ImageView imageview = new ImageView(this);
            imageview.setImageDrawable(getResources().getDrawable(R.drawable.nice_style));
            URL url = new URL("url_of_the_photo");
            Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
            imageview.setImageBitmap(bmp);
            linear_layout.addView(imageview);


不使用nice_style,我不确定如何为每个图像视图应用固定大小。我尝试添加LinearLayout.LayoutParams,但是只能设置widthheight,不能同时设置两者。

最佳答案

用它来赋予imageview高度和宽度。

imageview.setLayoutParams(new LayoutParams(width, height));

07-28 02:49
查看更多