How to change text field cursor position in jetpack compose

We can use TextFieldValue to change cursor position Initialise the TextFieldValue just like this var textFieldValueState by remember { mutableStateOf( TextFieldValue( text = “” ) ) } after initialising it set the TextFieldValue just like the below OutlinedTextField( value = textFieldValueState, onValueChange = { textFieldValueState = it }, … ) To append additional text and … Read more

Jetpack Compose how to remove EditText/TextField underline and keep cursor?

You can define these attributes to apply a Transparent color: focusedIndicatorColor unfocusedIndicatorColor disabledIndicatorColor Something like: TextField( //.. colors = TextFieldDefaults.textFieldColors( textColor = Color.Gray, disabledTextColor = Color.Transparent, backgroundColor = Color.White, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent ) ) Starting with 1.2.0 you can also use the new OutlinedTextFieldDecorationBox together with BasicTextField customizing the … Read more

Jetpack Compose Text hyperlink some section of the text

For a complete answer you can use ClickableText which returns the position of text, and UriHandler to open URI in a browser. val annotatedLinkString: AnnotatedString = buildAnnotatedString { val str = “Click this link to go to web site” val startIndex = str.indexOf(“link”) val endIndex = startIndex + 4 append(str) addStyle( style = SpanStyle( color … Read more

Toggle password field jetpack compose

You can use the standard TextField composable: var password by rememberSaveable { mutableStateOf(“”) } var passwordVisible by rememberSaveable { mutableStateOf(false) } TextField( value = password, onValueChange = { password = it }, label = { Text(“Password”) }, singleLine = true, placeholder = { Text(“Password”) }, visualTransformation = if (passwordVisible) VisualTransformation.None else PasswordVisualTransformation(), keyboardOptions = KeyboardOptions(keyboardType … Read more