I have two ImageViews as belows :
<ImageView android:id="@+id/image1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher" />
<ImageView android:id="@+id/image2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
/>
the first imageView displays image in its actual size, the second ImageView should displays image in fitCenter size.
I have been trying this code :
ImageView img1 = (ImageView) findViewById(R.id.image1);
ImageView img2 = (ImageView) findViewById(R.id.image2);
img2.setImageDrawable(img1.getDrawable());
but the second ImageView just displays image as the first one. Yes, in its actual size.
Can anyone help to find the solution?
Thanks
You can try something like this:
ImageView img2 = (ImageView) findViewById(R.id.image2);
img2.setScaleType(ImageView.ScaleType.CENTER_CROP);
img2.setImageDrawable(img1.getDrawable());