So I\'m loading images from a web service, but the size of the images are sometimes smaller or bigger than other images and the visualization looks silly when I put them in
Get ImageVIews as facebook posts.
Glide.with(context).load(link)
.placeholder(R.drawable.aboutlogo)
.fitCenter()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);`
<ImageView
android:id="@+id/img1"
android:src="@drawable/ic_menu_camera"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="center"/>
Just delete the maxHeight
and maxWidth
attributes and enter your units in layout_width
and layout_height
appropriately. But do not use the px
unit - use dp
instead, because these are device-independent.
This will fit the image in the specified height and width, irrespective of image size.
<ImageView
android:id="@+id/image5"
android:layout_width="300dp"
android:layout_height="200dp"
android:src="@drawable/image_1"
android:scaleType="fitXY"/>