Android text selection toolbar is not showing up while using SelectionContainer in Jetpack Compose
Asked Answered
F

0

9

I want to create selectable text using Jetpack Compose. Sample code is as following

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TextSelectionTheme {
                // A surface container using the 'background' color from the theme
                Surface(color = MaterialTheme.colors.background) {
                    Greeting("Android")
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String) {
    SelectionContainer(){
        Text(text = "Hello This is a sample text for testing out selections $name!")
    }

}

The problem is, it is showing only copy button near selection.

but when I use normal text view with isSelectable = true, it shows Android text selection toolbar,

Need help to understand how to show such toolbar in Jetpack compose when some text is selected and also is it possible to show More custom options ?

Farthermost answered 26/6, 2021 at 13:55 Comment(1)
I think you should create a feature request on compose issue tracker, right now such customisation doesn't seems to be supported.Riannon

© 2022 - 2024 — McMap. All rights reserved.