SemanticsPropertyKey

Function

Android
fun <T> SemanticsPropertyKey(
    name: String,
    accessibilityExtraKey: String,
    mergePolicy: (T?, T) -> T? = { parentValue, _ -> parentValue },
) =
    SemanticsPropertyKey(
        name = name,
        isImportantForAccessibility = false,
        accessibilityExtraKey = accessibilityExtraKey,
        mergePolicy = mergePolicy,
    )

Creates a SemanticsPropertyKey that allows declaring Android-specific semantics properties (key/value pairs set inside semantics blocks in a type-safe way) that are made available as accessibility extras provided to accessibility services via android.view.accessibility.AccessibilityNodeInfo.getExtras.

Each key has one particular statically defined value type T, where T is required to be either Serializable (which including boxed primitive types) or android.os.Parcelable.

If the same property is set multiple times, the last value set in the outer modifier wins.

Parameters

nameThe name of the property, which should be the same as the constant from which it is accessed.
accessibilityExtraKeyThe key used to store the value in the extras android.os.Bundle.
mergePolicyThe merge policy to use when merging descendant semantics.