ImageView

Displays an arbitrary image, such as an icon.

Examples

Embed a JPEG
<ImageView href="img/landscape.jpg" />
When using SVG images be sure to use deterministic sizes for the view
<ImageView href="img/appIcon.svg" width="32dp" height="32dp" />
Consider using a template expression to compute the deterministic size of the image on the server when using responsive layouts
<ImageView href="img/largeSymbol.svg"
    width="@{clientViewPortWidthPx}" height="@{clientViewPortWidthPx/3}" />
Set an HTTP URL to let the client load the image and scale it to fit into the view.
<ImageView width="3cm" height="2cm"
    href="https://example.com/great-image.jpg" scaleType="centerCrop"/>

Attributes

Name Type Default Binding Description

Inherits all attributes from View and adds the following:

href

URI

output

The link to the image file. This can be a local bitmap (png, jpeg, webp) or SVG file. The latter will be rendered by the server to fit the ImageView’s width and height. In this case, the ImageView must have deterministic width and height values. You must not use wrap_content or fill_parent in this case. Please consider computing the deterministic size by using a template expression.

You can also use HTTP URLs to set the image. The client will load the latter from the given URL itself.

maxWidth

sizeType

output

Makes the TextView be at most this wide.

maxHeight

sizeType

output

Makes the TextView be at most this tall.

scaleType

enum

platform-default

output

Controls how the image should be resized or moved to match the size of this ImageView. Allowed values: fitXY, fitStart, fitCenter, fitEnd, center, centerCrop and centerInside. Please refer to Amanda Hill’s Android ImageView ScaleType: A Visual Guide for more information.


Parts of this documentation are a derivate of the Android Developer Documentation by Google used under CC-BY-2.5.

results matching ""

    No results matching ""