Programatically apply aspect ratio to Imageview:
aspectRatio = imageWidth/imageHeight
ratioOfWidth = imageWidth/maxWidth
ratioOfHeight = imageHeight/maxHeight
if(ratioOfWidth > ratioOfHeight){???????
imageWidth = maxWidth
imageHeight = imageWidth/aspectRatio
}??????? else if(ratioOfHeight > ratioOfWidth){???????
imageHeight = maxHeight
imageWidth = imageHeight * aspectRatio
}???????
After that you can use scaled bitmap to image view
Bitmap scaledBitmap= Bitmap.createScaledBitmap(bitmap, (int) imageWidth , (int) imageHeight , true);