-3

I need a solution that how to find any images height and width that can fit totally in ImageView Height and width ?

Peter
  • 587
  • 6
  • 16
  • 1
    Your question is not clear. Do you want the image to stretch to your imageView? – Karthik CP Jan 23 '17 at 09:52
  • My question was I have completed all the coding part in Android,Now I need images . so I was asking about how to find the images height and width of .png format image to set in my app. – Peter Jan 24 '17 at 05:06

2 Answers2

1

You can get image width and height by its drawable;

int width = imgView.getDrawable().getIntrinsicWidth();
int height = imgView.getDrawable().getIntrinsicHeight();

And if you want your image to fit ImageView then you can use

<ImageView
    android:id="@id/img"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY" />

But you have a low-resolution image then it will distort.

pratik
  • 211
  • 2
  • 8
0

If you want your image to fit inside the image view without image distortion

<ImageView
    android:id="@id/img"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter" />
Karthik CP
  • 1,150
  • 13
  • 24