ScalableImageView

ScalableImageView
ScalableImageView

  1. ScalableImageView loading
  2. ScalableImageView loaded

ScalableImageView is an ImageView that scales the image to fit the imageHeight and imageWidth provided so it is able to show a loading place holder with the right size before the image is loaded, avoiding "jumps" in the screen after your image is loaded.

ScalableImageView allows restricting the height of the image to not be larger than the parent RecyclerView height so the user never has to scroll to see the whole image. To do this, set the property maximumHeightOneScreen to true.

Usage

You can set it up in code or in the layout:

In code:

var maximumHeightOneScreen: Boolean = false
var imageHeight: Int? = null
var imageWidth: Int? = null
In the layout:
<com.poqstudio.app.platform.view.common.ScalableImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
app:imageHeight="@{viewModel.imageHeight}"
app:imageUrl="@{viewModel.imageUrl}"
app:imageWidth="@{viewModel.imageWidth}"
app:maximumHeightOneScreen="@{true}"
app:shimmerPlaceholder="@{true}" />