ImageView

代码实现imageView的大小
// SET THE IMAGEVIEW DIMENSIONS  
int dimens = 120;  
float density = activity.getResources().getDisplayMetrics().density;  
int finalDimens = (int)(dimens * density);  
  
LinearLayout.LayoutParams imgvwDimens =   
        new LinearLayout.LayoutParams(finalDimens, finalDimens);  
imgAlbumPhoto.setLayoutParams(imgvwDimens);  
  
// SET SCALETYPE  
imgAlbumPhoto.setScaleType(ScaleType.CENTER_CROP);  
  
// SET THE MARGIN  
int dimensMargin = 5;  
float densityMargin = activity.getResources().getDisplayMetrics().density;  
int finalDimensMargin = (int)(dimensMargin * densityMargin);  
  
LinearLayout.LayoutParams imgvwMargin =   
        new LinearLayout.LayoutParams(finalDimens, finalDimens);  
imgvwMargin.setMargins  
(finalDimensMargin, finalDimensMargin, finalDimensMargin, finalDim  
  
ensMargin);  

改变已经存在的imageView的大小

coupon_img.setLayoutParams(new LayoutParams(100, 100));


你可能感兴趣的:(ImageView)