Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this code for re-sizing it:</p> <pre><code>Display display = getWindow().getWindowManager().getDefaultDisplay(); int hsize= (int) ((int)display.getHeight()-(display.getHeight()*(0.50))); int wsize= (int) ((int)display.getWidth()-(display.getWidth()*0.25)); Bitmap originalImage=decodeSampledBitmapFromResource(getResources(),imageId,wsize,hsize); ImageView imageView = new ImageView(mContext); imageView.setImageBitmap(scaleBitmap(originalImage)); imageView.setLayoutParams(new CoverFlow.LayoutParams(wsize,hsize)); imageView.setScaleType(ScaleType.MATRIX); public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) { // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(res, resId, options); // Calculate inSampleSize options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); // Decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeResource(res, resId, options); } public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height &gt; reqHeight || width &gt; reqWidth) { if (width &gt; height) { inSampleSize = Math.round((float)height / (float)reqHeight); } else { inSampleSize = Math.round((float)width / (float)reqWidth); } } return inSampleSize; } private Bitmap scaleBitmap(Bitmap bitmap) { int iWidth=bitmap.getWidth() ; int iHeight=bitmap.getHeight(); int newWidth=0,newHeight=0; float fFactor=(float)iHeight/(float)iWidth; if(iWidth&lt;=iHeight) { newWidth = 300; newHeight =(int) (newWidth * fFactor) ;//370; } else { newWidth = 400; newHeight =(int) (newWidth * fFactor) ;//370; } float fScaleWidth = ((float) newWidth) / iWidth; float fScaleHeight = ((float) newHeight) / iHeight; Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(fScaleWidth, fScaleHeight); Bitmap resizedBitmappreview = Bitmap.createBitmap(bitmap, 0, 0,iWidth, iHeight, matrix, true); return resizedBitmappreview; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload