Answers for "resize imageview android programmatically"

3

how to resize image in android programmatically

public static Bitmap resizeImage(Bitmap realImage, float maxImageSize,
        boolean filter) {
    float ratio = Math.min(
            (float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
            height, filter);
    return newBitmap;
}
Posted by: Guest on January-15-2021
0

set ImageView size programmatically android

imageView.getLayoutParams().height = 20;
// If you're setting the height after the layout has already been 'laid out',
// make sure you also call:
imageView.requestLayout();
Posted by: Guest on April-23-2022

Code answers related to "resize imageview android programmatically"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language