Dev*_*tal 9 material-components-android android-jetpack-compose
我想使用 Jetpack Compose 创建可选文本。示例代码如下
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!")
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,它只在选择附近显示复制按钮。
但是当我使用普通文本视图时isSelectable = true
,它显示Android文本选择工具栏,
需要帮助了解如何在选择某些文本时在 Jetpack compose 中显示此类工具栏,并且是否可以显示更多自定义选项?
归档时间: |
|
查看次数: |
697 次 |
最近记录: |