I'm trying to replicate some View-based selected text behavior with Jetpack Compose. In both of these cases, I've long-tapped on the middle of the URL.
View based:
<TextView ... android:textIsSelectable="true" />

Compose:
SelectionContainer {
Text(...)
}

As you can see in the screenshots, there are a few missing options in the Compose layout. Is there a way to add this? Yes, I know I can use AndroidView but is there a more composey way to do it? Here's what's in the View layout, but lacking from the Compose layout:
Edit: I'm not asking for a custom toolbar, I'm asking for the one Google provides in TextView.
While this is still not supported, if you use a TextField instead of a Text you at least get the "Select all" option too.
@Composable
private fun SelectableTextField() {
TextField(
value = "This is a selectable text",
onValueChange = {},
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
readOnly = true,
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent
)
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With