简体   繁体   中英

Set fixed size and drawable style for each ImageView

My current try:

            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);

Doesn't use nice_style and I am not sure how I could apply fixed size for each imageview. I tried adding LinearLayout.LayoutParams , but I can set only width or height , not both.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM