I have an imageview
that has its height and width set to fill_parent
with a linearlayout
that has the same values set. So I suppose th
I Have used this android:scaleType="fitXY"
code in Xml file.
The accepted answer is perfect, however if you want to do it from xml, you can use android:scaleType="fitXY"
just change your ImageView height and width to wrap_content and use
exampleImage.setScaleType(ImageView.ScaleType.FIT_XY);
in your code.
for XML android
android:src="@drawable/foto1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
Trying using :
imageview.setFitToScreen(true);
imageview.setScaleType(ScaleType.FIT_CENTER);
This will fit your imageview to the screen with the correct ratio.
to change pro-grammatically use :
imgview.setScaleType(ScaleType.FIT_XY);
OR
to change from xml use:
android:scaleType="fitXY"