VisualTransformation

Interface

Common
fun interface VisualTransformation

Interface used for changing visual output of the input field.

This interface can be used for changing visual output of the text in the input field. For example, you can mask characters in password field with asterisk with PasswordVisualTransformation.

Functions

fun filter(text: AnnotatedString): TransformedText

Change the visual output of given text.

Note that the returned text length can be different length from the given text. The composable will call the offset translator for converting offsets for various reasons, cursor drawing position, text selection by gesture, etc.

The ASCII only password (replacing with '*' chars) original text : thisispassword transformed text: **************

Credit Card Visual Output (inserting hyphens each 4 digits) original text : 1234567890123456 transformed text: 1234-5678-9012-3456

Parameters

textThe original text

Returns

the pair of filtered text and offset translator.