簡體   English   中英

為每個ImageView設置固定大小和可繪制樣式

[英]Set fixed size and drawable style for each ImageView

我目前的嘗試:

            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 ,我不確定如何為每個imageview應用固定大小。 我嘗試添加LinearLayout.LayoutParams ,但只能設置widthheight ,不能同時設置兩者。

用它來賦予imageview高度和寬度。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM