I would like to dynamically resize my images taken from camera in android. I want an output like the pinterest images.
You can set the ImageView's width to your custom size, its height to wrap_content and the important thing is to set the ImageView's scaleType to fitXY
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="100dp" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/yourImage1"/> <ImageView android:layout_width="100dp" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/yourImage2"/> </LinearLayout>
You can set the ImageView's width to your custom size, its height to wrap_content and the important thing is to set the ImageView's scaleType to fitXY