2013-12-23 82 views
0

我目前的嘗試:設置固定的大小和樣式繪製每個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,而不是兩者。

+0

使用此圖像view.setLayoutParams(new LayoutParams(width,height)); – mayuri

回答

0

使用此給予高度和寬度imageview。

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

它似乎工作,謝謝。那個「drawable」呢? –

+0

即時消息不只有一個imageview – mayuri

+0

有很多imageview我創建 –

相關問題