androidx.wear.protolayout.types


Classes

LayoutString

Static or dynamic string value for layout fields.

Top-level functions summary

TypeBuilders.StringLayoutConstraint
@RequiresSchemaVersion(major = 1, minor = 200)
stringLayoutConstraint(longestPattern: String, alignment: Int)

Specifies layout constraints for to use for layout measurement in presence of dynamic values.

Extension functions summary

TypeBuilders.StringLayoutConstraint
@RequiresSchemaVersion(major = 1, minor = 200)
String.asLayoutConstraint(alignment: Int)

Extension for creating a StringLayoutConstraint from a String.

LayoutString
@RequiresSchemaVersion(major = 1, minor = 200)
DynamicBuilders.DynamicString.asLayoutString(
    staticValue: String,
    layoutConstraint: TypeBuilders.StringLayoutConstraint
)

Extension for creating a LayoutString from a DynamicString

Extension properties summary

LayoutString

Extension for creating a LayoutString from a String.

Top-level functions

stringLayoutConstraint

@RequiresSchemaVersion(major = 1, minor = 200)
fun stringLayoutConstraint(
    longestPattern: String,
    alignment: Int = TEXT_ALIGN_CENTER
): TypeBuilders.StringLayoutConstraint

Specifies layout constraints for to use for layout measurement in presence of dynamic values.

Parameters
longestPattern: String

the text string to use as the pattern for the (graphically) longest text that can be laid out. Used to ensure that the layout is of a known size during the layout pass.

alignment: Int = TEXT_ALIGN_CENTER

the alignment of the actual text within the space reserved by longestPattern

Extension functions

asLayoutConstraint

@RequiresSchemaVersion(major = 1, minor = 200)
fun String.asLayoutConstraint(alignment: Int = TEXT_ALIGN_CENTER): TypeBuilders.StringLayoutConstraint

Extension for creating a StringLayoutConstraint from a String. this will be used as longestPattern.

Parameters
alignment: Int = TEXT_ALIGN_CENTER

the alignment of the actual text within the space reserved by longestPattern

@RequiresSchemaVersion(major = 1, minor = 200)
fun DynamicBuilders.DynamicString.asLayoutString(
    staticValue: String,
    layoutConstraint: TypeBuilders.StringLayoutConstraint
): LayoutString

Extension for creating a LayoutString from a DynamicString

Parameters
staticValue: String

the static value that can be used when the dynamicValue can't be resolved.

layoutConstraint: TypeBuilders.StringLayoutConstraint

used to correctly measure layout Text element size and align text to ensure that the layout is of a known size during the layout pass regardless of the dynamicValue String.

Extension properties

val String.layoutStringLayoutString

Extension for creating a LayoutString from a String.