LayoutElementBuilders.Image.Builder


class LayoutElementBuilders.Image.Builder


Builder for Image.

Summary

Public constructors

This function is deprecated.

Use Builder constructor which supports automatic resource registration, paired with setImageResource.

Creates an instance of Builder with automatic resource registration used.

Public functions

LayoutElementBuilders.Image

Builds an instance with values accumulated in this Builder.

LayoutElementBuilders.Image.Builder

Sets filtering parameters for this image.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setContentScaleMode(contentScaleMode: Int)

Sets how to scale the image resource inside the bounds specified by width/height if its size does not match those bounds.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setContentScaleMode(
    contentScaleMode: LayoutElementBuilders.ContentScaleModeProp
)

Sets how to scale the image resource inside the bounds specified by width/height if its size does not match those bounds.

LayoutElementBuilders.Image.Builder

Sets the height of this image.

LayoutElementBuilders.Image.Builder

Sets the specific resource of the image to render.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setImageResource(
    resource: ResourceBuilders.ImageResource,
    resourceId: String
)

Sets the specific resource of the image to render.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setModifiers(modifiers: ModifiersBuilders.Modifiers)

Sets androidx.wear.protolayout.ModifiersBuilders.Modifiers for this element.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setResourceId(resourceId: String)

This function is deprecated.

Use setImageResource paired with Builder for automatic resource registration.

LayoutElementBuilders.Image.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setResourceId(resourceId: TypeBuilders.StringProp)

This function is deprecated.

Use setImageResource paired with Builder for automatic resource registration.

LayoutElementBuilders.Image.Builder

Sets the width of this image.

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.4.0-alpha01
Builder()

Creates an instance of Builder.

Note that, when using this constructor, it should be paired with setResourceId, and resource used for it needs to be manually registered in TileService#onTileResourcesRequest for Tiles. This constructor can't be mixed with setImageResource, otherwise an exception will be thrown.

Builder

Added in 1.4.0-alpha01
Builder(scope: ProtoLayoutScope)

Creates an instance of Builder with automatic resource registration used.

Note that, when using this constructor, it should be paired with setImageResource. Additionally, Resources object shouldn't be provided in TileService#onTileResourcesRequest method for your Tile as resources would be automatically registered. This constructor can't be mixed with setResourceId, otherwise an exception will be thrown.

When using this constructor and automatic resource registration, there's no need to provide resources version in Tile.Builder.setResourcesVersion, as ProtoLayoutScope will handle versioning and changes of the resources automatically. However, setting custom version in Tile.Builder.setResourcesVersion is still supported.

Public functions

build

Added in 1.0.0
fun build(): LayoutElementBuilders.Image

Builds an instance with values accumulated in this Builder.

setColorFilter

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setColorFilter(colorFilter: LayoutElementBuilders.ColorFilter): LayoutElementBuilders.Image.Builder

Sets filtering parameters for this image. If not specified, defaults to no filtering.

setContentScaleMode

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setContentScaleMode(contentScaleMode: Int): LayoutElementBuilders.Image.Builder

Sets how to scale the image resource inside the bounds specified by width/height if its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.

setContentScaleMode

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setContentScaleMode(
    contentScaleMode: LayoutElementBuilders.ContentScaleModeProp
): LayoutElementBuilders.Image.Builder

Sets how to scale the image resource inside the bounds specified by width/height if its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.

setHeight

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setHeight(height: DimensionBuilders.ImageDimension): LayoutElementBuilders.Image.Builder

Sets the height of this image. If not defined, the image will not be rendered.

setImageResource

Added in 1.4.0-alpha01
@RequiresSchemaVersion(major = 1, minor = 0)
fun setImageResource(resource: ResourceBuilders.ImageResource): LayoutElementBuilders.Image.Builder

Sets the specific resource of the image to render. This method will automatically assign the ID and add the given resource in the resources bundle.

Parameters
resource: ResourceBuilders.ImageResource

An Image resource, used in the layout in the place of this Image element.

Throws
java.lang.IllegalStateException

if this method is called without Builder or after setResourceId was already called.

setImageResource

Added in 1.4.0-alpha01
@RequiresSchemaVersion(major = 1, minor = 0)
fun setImageResource(
    resource: ResourceBuilders.ImageResource,
    resourceId: String
): LayoutElementBuilders.Image.Builder

Sets the specific resource of the image to render. This method will automatically add the given resource in the resources bundle.

Parameters
resource: ResourceBuilders.ImageResource

An Image resource, used in the layout in the place of this Image element.

resourceId: String

The ID of the resource

Throws
java.lang.IllegalStateException

if this method is called without Builder or after setResourceId was already called.

setResourceId

Added in 1.0.0
Deprecated in 1.4.0-alpha01
@RequiresSchemaVersion(major = 1, minor = 0)
fun setResourceId(resourceId: String): LayoutElementBuilders.Image.Builder

Sets the resource_id of the image to render. This must exist in the supplied resource bundle.

Throws
java.lang.IllegalStateException

if this method is called with Builder or after setImageResource was already called.

setResourceId

Added in 1.0.0
Deprecated in 1.4.0-alpha01
@RequiresSchemaVersion(major = 1, minor = 0)
fun setResourceId(resourceId: TypeBuilders.StringProp): LayoutElementBuilders.Image.Builder

Sets the resource_id of the image to render. This must exist in the supplied resource bundle.

Note that this field only supports static values.

Throws
java.lang.IllegalStateException

if this method is called with Builder or after setImageResource was already called.

setWidth

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setWidth(width: DimensionBuilders.ImageDimension): LayoutElementBuilders.Image.Builder

Sets the width of this image. If not defined, the image will not be rendered.